<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Joy Kyalo on Medium]]></title>
        <description><![CDATA[Stories by Joy Kyalo on Medium]]></description>
        <link>https://medium.com/@jlohreen?source=rss-1aa9704fb219------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*l7JeLKw7LRhyAVYc</url>
            <title>Stories by Joy Kyalo on Medium</title>
            <link>https://medium.com/@jlohreen?source=rss-1aa9704fb219------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 15:44:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jlohreen/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How Statistics Can Be Used to Drive Business Decisions: A Case Study]]></title>
            <link>https://medium.com/@jlohreen/how-statistics-can-be-used-to-drive-business-decisions-a-case-study-64e4780345b3?source=rss-1aa9704fb219------2</link>
            <guid isPermaLink="false">https://medium.com/p/64e4780345b3</guid>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Joy Kyalo]]></dc:creator>
            <pubDate>Mon, 02 Feb 2026 09:00:02 GMT</pubDate>
            <atom:updated>2026-02-02T09:00:02.769Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Businesses today collect vast amounts of data from sales transactions, marketing campaigns, and customer interactions. However, data alone is<strong> </strong>not useful<strong> </strong>, it must be analyzed and interpreted to guide decisions.</p><p>This article shows how <strong>statistics</strong> can be used to evaluate <strong>sales performance</strong> and <strong>marketing effectiveness</strong> using a retail company’s three-year sales data. The goal is to provide clear insights and actionable recommendations for business decision-making.</p><h3>Problem Statement</h3><p>A retail company operating <strong>online and physical stores</strong> wanted answers to three main questions:</p><ol><li>How are sales performing overall?</li><li>How reliable are the insights derived from sales data?</li><li>Does a marketing campaign actually increase revenue per transaction?</li></ol><p>To address these questions, the company analyzed <strong>transaction-level data</strong> including:</p><ul><li>Date of transaction</li><li>Store type (Online/Physical)</li><li>Region of sale</li><li>Units sold</li><li>Revenue</li></ul><h3>Statistical Methods Used</h3><p>To answer these questions, several statistical methods were applied:</p><h3>1. Descriptive Statistics</h3><ul><li><strong>Measures of Central Tendency</strong>: Mean, median, and mode were calculated to summarize typical monthly revenue.</li><li><strong>Measures of Dispersion</strong>: Range, variance, and standard deviation were calculated to understand revenue variability.</li><li><strong>Distribution Shape</strong>: Skewness and kurtosis helped assess whether the data was normally distributed or skewed.</li></ul><h3>2. Data Visualization</h3><ul><li><strong>Line charts</strong> to show revenue trends over time</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*lKb_tgGRePxIXK9gA6CB5g.png" /></figure><ul><li><strong>Bar charts</strong> to compare revenue by store type</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*D4Y4hC75lYbq_ZfJjZgB5Q.png" /></figure><ul><li><strong>Box plots</strong> to explore revenue distribution by region</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*tdEPjdXOjKFTmQYmGzF0NQ.png" /></figure><ul><li><strong>Scatter plots</strong> to examine relationships between variables, e.g., marketing campaigns and revenue</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*xB-g8oozbnpaKX4z_6Gimg.png" /></figure><h3>3. Sampling and Bias Awareness</h3><ul><li>Understanding the difference between population and sample</li><li>Identifying selection bias when only certain stores were included</li><li>Proposing <strong>stratified random sampling</strong> to ensure representative data</li></ul><h3>4. Probability Laws</h3><ul><li><strong>Law of Large Numbers (LLN)</strong>: Verified that larger samples provide more stable estimates of average revenue</li><li><strong>Central Limit Theorem (CLT)</strong>: Showed that sample means follow a normal distribution even if revenue data is skewed</li></ul><h3>5. Hypothesis Testing</h3><ul><li><strong>Question:</strong> Does running a marketing campaign increase revenue per transaction?</li><li><strong>Method:</strong> One-tailed t-test with 95% confidence level</li><li><strong>Effect Size:</strong> Cohen’s d to measure practical significance</li></ul><h3>6. Errors and Interpretation</h3><ul><li><strong>Type I Error:</strong> Concluding a campaign works when it does not</li><li><strong>Type II Error:</strong> Failing to detect a real campaign effect</li><li><strong>Power considerations:</strong> More data can improve decision confidence</li></ul><h3>Key Findings</h3><ol><li><strong>Sales Performance</strong></li></ol><ul><li>Average monthly revenue is around <strong>KES 248,000</strong>, but revenue fluctuates due to seasonality and campaigns.</li><li>The median revenue is a better measure than the mean due to the presence of high-revenue outliers.</li></ul><p><strong>2. Marketing Effectiveness</strong></p><ul><li>Transactions during marketing campaigns generate <strong>higher revenue</strong> than those without campaigns.</li><li>Statistical testing shows this difference is <strong>significant</strong>, with a <strong>medium to large effect size</strong></li></ul><p><strong>3. Revenue Distribution</strong></p><ul><li>Revenue data is Negatively <strong>skewed</strong>, with a few months showing very high revenue.</li><li>Certain regions show more variability, highlighting the need for tailored business strategies.</li></ul><p><strong>4. Sampling Considerations</strong></p><ul><li>Sampling only urban stores would <strong>overestimate revenue</strong>, stressing the importance of representative sampling.</li></ul><h3>Business Implications</h3><ul><li><strong>Data-Driven Decisions:</strong> Median revenue and standard deviation provide clear insights into typical sales and variability, helping plan budgets and inventory.</li><li><strong>Marketing Strategy:</strong> Evidence supports expanding marketing campaigns for higher revenue.</li><li><strong>Regional Planning:</strong> Some regions are more volatile; targeted strategies may optimize resource allocation.</li><li><strong>Sampling Awareness:</strong> Ensuring representative data prevents misleading conclusions.</li><li><strong>Continuous Monitoring:</strong> Using LLN and CLT principles helps managers understand when observed trends are reliable or random.</li></ul><h3>Conclusion</h3><p>Statistics is a <strong>powerful tool</strong> that allows businesses to transform raw sales data into actionable insights. By using descriptive analysis, visualization, hypothesis testing, and careful sampling, businesses can:</p><ul><li>Identify performance trends</li><li>Evaluate the effectiveness of marketing</li><li>Make confident, evidence-based decisions</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64e4780345b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ridge Regression vs Lasso Regression: A Comprehensive Guide]]></title>
            <link>https://medium.com/@jlohreen/ridge-regression-vs-lasso-regression-a-comprehensive-guide-81f292766d0b?source=rss-1aa9704fb219------2</link>
            <guid isPermaLink="false">https://medium.com/p/81f292766d0b</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Joy Kyalo]]></dc:creator>
            <pubDate>Sun, 25 Jan 2026 18:31:20 GMT</pubDate>
            <atom:updated>2026-01-25T18:31:20.924Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Ordinary Least Squares (OLS)</h3><p><strong>What is OLS and what does it minimize?</strong></p><p>Ordinary Least Squares is the standard method for fitting a linear regression model. It finds the line that best fits the data by minimizing the sum of squared residuals.</p><p>The objective function OLS minimizes is</p><p><strong>Loss = Σ(yᵢ — ŷᵢ)²</strong></p><p>Where:</p><ul><li>yᵢ is the actual house price</li><li>ŷᵢ is the predicted house price</li></ul><p>In house price prediction, if OLS predicts a house at $300,000 but it actually sold for $320,000, the squared residual is ($20,000)² = $400,000,000. OLS finds coefficients that make the total of all these squared errors as small as possible.</p><p><strong>Why can OLS lead to overfitting?</strong></p><p>OLS can overfit in several scenarios:</p><ul><li><strong>Too many features</strong>: If you have 100 features but only 50 houses in your training data, OLS will find a perfect fit to the training data but perform terribly on new houses.</li><li><strong>Correlated features</strong>: OLS might assign a huge positive coefficient to one and a huge negative coefficient to the other, creating an unstable model that’s very sensitive to small data changes.</li><li><strong>Noisy features</strong>: If you include irrelevant features like “house number on the street,” OLS will still try to use them, potentially finding spurious patterns in the training data that don’t generalize.</li></ul><h3>2. The Concept of Regularization</h3><p><strong>What problem does regularization solve?</strong></p><p>Regularization addresses overfitting by discouraging overly complex models. The problem it solves is that OLS only cares about fitting the training data perfectly, not about whether the model will work well on new, unseen data.</p><p><strong>Why is adding a penalty term helpful?</strong></p><p>Adding a penalty term creates a trade-off: the model must balance fitting the data well against keeping coefficients small and simple.</p><h3>3. Ridge Regression (L2 Regularization)</h3><p><strong>Ridge regression loss function:</strong></p><p><strong>Loss = Σ(yᵢ — ŷᵢ)² + λΣβⱼ²</strong></p><p>Where:</p><ul><li>The first term is the OLS loss (fitting the data)</li><li>The second term is the L2 penalty (sum of squared coefficients)</li><li>λ (lambda) is the regularization parameter controlling the trade-off</li><li>βⱼ represents each coefficient in the model</li></ul><p><strong>How the L2 penalty affects coefficients:</strong></p><p>The L2 penalty shrinks all coefficients toward zero, but never exactly to zero. The larger λ is, the more aggressive the shrinkage.</p><p>All coefficients get smaller, but all remain in the model.</p><p><strong>Why Ridge doesn’t perform feature selection:</strong></p><p>The L2 penalty (squaring coefficients) means that making a coefficient slightly smaller always provides some benefit, but the benefit decreases as the coefficient approaches zero. The squared penalty creates a smooth, differentiable function that doesn’t have a sharp corner at zero, so coefficients approach zero but don’t reach it.</p><h3>4. Lasso Regression (L1 Regularization)</h3><p><strong>Lasso regression loss function:</strong></p><p><strong>Loss = Σ(yᵢ — ŷᵢ)² + λΣ|βⱼ|</strong></p><p>Where:</p><ul><li>The first term is still the OLS loss</li><li>The second term is the L1 penalty (sum of absolute values of coefficients)</li><li>λ controls the regularization strength</li></ul><p><strong>How L1 differs from L2:</strong></p><p>The key difference is using absolute values instead of squares. This might seem like a small mathematical change, but it has profound implications:</p><ul><li><strong>L2 (Ridge)</strong>: Penalizes large coefficients much more heavily than small ones . A coefficient of 10 contributes 100 to the penalty, while a coefficient of 2 contributes only 4.</li><li><strong>L1 (Lasso)</strong>: Penalizes coefficients proportionally to their absolute size. A coefficient of 10 contributes 10 to the penalty, while a coefficient of 2 contributes 2. The penalty rate is constant regardless of coefficient size.</li></ul><p><strong>Why Lasso can set coefficients exactly to zero:</strong></p><p>The L1 penalty creates a sharp corner at zero. When optimizing, the solution often “hits” this corner, forcing coefficients to be exactly zero. The constant penalty rate means that for weak features, the cost of keeping them outweighs the benefit, so they get completely removed from the model.</p><h3>5. Comparing Ridge and Lasso Regression</h3><p><strong>Three key differences:</strong></p><p><strong>Feature Selection</strong></p><ul><li><strong>Ridge</strong>: Keeps all features, shrinks them all toward zero, but retains everything.</li><li><strong>Lasso</strong>: Performs automatic feature selection by setting weak feature coefficients to exactly zero.</li></ul><p><strong>Coefficient Behavior</strong></p><ul><li><strong>Ridge</strong>: Shrinks coefficients smoothly and proportionally. Correlated features tend to have similar, non-zero coefficients.</li><li><strong>Lasso</strong>: Makes hard choices among correlated features, often picking one and eliminating others.</li></ul><p><strong>Model Interpretability</strong></p><ul><li><strong>Ridge</strong>: Less interpretable because you have many small coefficients. Looking at your house price model, you see 50 features all contributing a little bit, making it hard to explain which features really matter.</li><li><strong>Lasso</strong>: More interpretable because it produces sparse models. You can say, “House prices depend on these 8 specific features,” and ignore the rest. This creates a clearer story about what drives prices.</li></ul><h3>6. Application Scenario: House Price Prediction</h3><h3>a. When all features contribute to price</h3><p><strong>Choose Ridge Regression</strong></p><p>If you genuinely believe that size, bedrooms, distance to city, schools, and even smaller factors all contribute to house prices, Ridge is the better choice because:</p><ul><li><strong>Preserves all information</strong>: Ridge keeps everything while preventing overfitting through shrinkage.</li><li><strong>Handles correlated features well</strong>: Ridge handles these correlations gracefully by distributing coefficients among correlated features.</li><li><strong>Stability</strong>: Ridge produces more stable predictions because small changes in training data don’t completely eliminate features .</li></ul><h3>b. When only a few features are truly important</h3><p><strong>Choose Lasso Regression</strong></p><p>If only a handful of features truly drive house prices and the rest are noise, Lasso is superior because:</p><ul><li><strong>Automatic feature selection</strong>: Lasso will identify the important features and zero out the rest.</li><li><strong>Reduced overfitting</strong>: By eliminating noisy features entirely, Lasso prevents the model from finding spurious patterns in irrelevant data.</li></ul><h3>7. Model Evaluation</h3><p><strong>Using training and testing data to detect overfitting:</strong></p><p>The fundamental approach is to split your house price data into two sets:</p><ul><li><strong>Training set</strong> (typically 70–80% of data): Used to fit the model</li><li><strong>Testing set</strong> (remaining 20–30%): Used only to evaluate the fitted model</li></ul><p>Overfitting is detected through the training-testing performance gap:</p><ol><li><strong>Train your model</strong> (OLS, Ridge, or Lasso) on the training set</li><li><strong>Calculate error metrics</strong> on both training and testing sets</li><li><strong>Compare the errors</strong>:</li></ol><ul><li><strong>Small gap</strong>: Model generalizes well (desired outcome)</li><li><strong>Large gap</strong>: Model is overfitting (memorizing training data)</li></ul><p><strong>Role of residuals in evaluation:</strong></p><p>Residuals (the differences between actual and predicted prices) are diagnostic tools that reveal model quality:</p><p><strong>What residuals tell us:</strong></p><ul><li><strong>Magnitude</strong>: Large residuals indicate poor predictions. If your model predicts $300,000 for a house that sold for $500,000, that $200,000 residual signals a problem.</li><li><strong>Patterns in residuals</strong>: Good models have residuals that look like random noise with no patterns. Patterns indicate the model is missing something systematic.</li></ul><p><strong>Residual analysis for house prices:</strong></p><ul><li><strong>Against predicted values</strong>: Residuals should be randomly scattered. If you see residuals growing with price, the model’s errors are inconsistent across price ranges.</li><li><strong>Against features</strong>: If residuals increase systematically with “distance to city,” your model isn’t capturing that relationship correctly.</li><li><strong>Distribution</strong>: Residuals should be roughly normally distributed around zero. If they’re skewed, the model has systematic .</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81f292766d0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hospital Performance and Financial Dashboard.]]></title>
            <link>https://medium.com/@jlohreen/hospital-performance-and-financial-dashboard-fa6101ec485e?source=rss-1aa9704fb219------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa6101ec485e</guid>
            <category><![CDATA[dashboard]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Joy Kyalo]]></dc:creator>
            <pubDate>Mon, 01 Dec 2025 05:55:12 GMT</pubDate>
            <atom:updated>2025-12-01T05:55:12.432Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction.</h3><p>The objective was to build a hospital dashboard analyzing operational efficiency, doctor performance and financial risk using PostgreSQL data visualized in Power BI.</p><h4>Data Connection and Cleaning.</h4><p><strong>Source:</strong> Connected Power BI to postgreSQL source to fetch and load the data needed for the visualization.</p><p><strong>Views: </strong>The analysis was based on pre-aggregated SQL views (hospital_appointments_enriched ,Doctor_Monthly_Metrics , Patient_Balances) to improve perfomance and simplify the Power BI model.</p><p><strong>Cleaning: </strong>Ensured all table columns were in the correct data type.</p><p>Loaded dimension tables(patients, doctors and admissions) separately to help in creating relationships.</p><h3><strong>Data Modeling Decisions.</strong></h3><p>Implemented a Star Schema to allow time-based filtering across all tables.</p><p><strong>Time Analysis: </strong>Created a dimensional table date and linked via One-to-Many relationship to the appointmentdate column.</p><p><strong>Financial Filtering Path: </strong>Linked time-based filters to the financial view.</p><p>Date filters Appointments which filters patients via PatientID which finally filters the Hospital_patient_balance view.This allows a date slicer to analyze outstanding debt ncurred during a specific period.</p><p><strong>KPI Development: </strong>Measures were created to track key metrics ,including <strong>Total Appointments</strong>, <strong>Cancellation Rate (%)</strong>, and <strong>Total Outstanding Balance</strong>. The <strong>Appointments YOY Change (%)</strong> was confirmed to be structurally correct but remains blank, as the current dataset only contains data from <strong>2021</strong>.</p><h3>Dashboard Pages and Key Insights</h3><p>The final report is organized into three pqges ,each adressing a specific business objective.</p><p><strong>Page 1:Executive overview.</strong></p><p>Focuses on summary of critical outcomes and trend monitoring.</p><p>Three KPI cards display current status(Total appointments, Total Outstanding balance , Cancellation rate %) and primary indicators of efficiency and growth.</p><p>The time trend line chart provides a clear vision of total appointments overtime ,quickly revealing seasonal drops or periods of growth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*qlR6MtXoHBPud2hiqWrU7A.png" /></figure><p><strong>Page 2:Appointment Analysis.</strong></p><p>Focuses on doctor productivity and cancellation review.</p><p>A scatter plot is used for effective performance identification.</p><p>High-performing providers are identified enabling for quick-addressing of low-performing providers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*A4ogdJoj99erECVOvl_7ag.png" /></figure><p><strong>Page3:Financial</strong></p><p><strong>Fo</strong>cuses on financial risks and liability concentration.</p><p>A table visual applies a Top N(top 10 patients) filter and is sorted by Total Outstanding Balance , highlighting the individuals representing the highest financial risk.</p><p>A tree map visualizes the distribution of Total Outstanding Balance by time period ,showing which months generated the most long-term debt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*o_IDXiGIehmdx2uPYIjcyQ.png" /></figure><h3>Finalization and Deployment</h3><p>To ensure the report remains dynamic, the On-premises Data Gateway was installed and configured. This secured gateway acts as a bridge, allowing the Power BI Service to connect to the internal PostgreSQL database using defined credentials and refresh the published dataset on a scheduled basis.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa6101ec485e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Connect PostgreSQL to Power BI Using Local PostgreSQL and Aiven.]]></title>
            <link>https://medium.com/@jlohreen/how-to-connect-postgresql-to-power-bi-using-local-postgresql-and-aiven-f748e07b628b?source=rss-1aa9704fb219------2</link>
            <guid isPermaLink="false">https://medium.com/p/f748e07b628b</guid>
            <dc:creator><![CDATA[Joy Kyalo]]></dc:creator>
            <pubDate>Sun, 23 Nov 2025 11:24:31 GMT</pubDate>
            <atom:updated>2025-11-23T11:28:04.654Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0GLlMdvPOpKvU58GlGksdQ.png" /></figure><ol><li><strong>Connecting Power BI to Local PostgreSQL</strong></li></ol><p>a)Open Power BI and Select the Connector</p><ul><li>In Power BI ,navigate to home tab.</li><li>-Click get data and then more ,select PostgreSQL database and click connect.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DwgR_0LgPwIN4SWh8dDCsQ.png" /></figure><p>b)Enter connection details</p><ul><li>A dialog box will appear asking for the server and database.</li><li>Since the database is local the server is likely localhost.</li><li>Enter the name of your specific database(e.g., hospital).</li><li>For Data connectivity mode ,choose import.</li></ul><p>c)Authenticate the connection.</p><ul><li>Power Bi will prompt you for credentials.</li><li>Enter your Username and password.</li><li>Click connect.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WJJDEzjs7aCZyR7JapHJOA.png" /></figure><p>d)Load your Data.</p><ul><li>The navigator window will display all tables and views in your specified database.</li><li>Select tables you wish to import.</li><li>You can either load the data directly if it’s already cleaned or click Transform Data to open the power Query Editor for cleaning.</li></ul><p><strong>2.Connecting Power BI to PostgreSQL Hosted on Aiven.</strong></p><p>First you will need to download CA certificate from Aiven.</p><p>Install the certificate in windows:</p><p>Open Manage Computer certificates from the search bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*7Qzkp83d1VnqPyguXexdMw.png" /></figure><p>-In the left pane, expand <strong>Trusted Root Certification Authorities</strong>.</p><p>-Right-click on Certificates.</p><p>-Select All Tasks &gt; Import</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*KQkQylxzvXKC2Yl3RUwbQw.png" /></figure><p>The Certificate Import Wizard will open. Click Next.</p><p>Click Browse and navigate to your downloaded ca.pem file</p><p>You may need to change the file type dropdown filter to All Files <strong>(*.*)</strong> to see the .pem file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*4f7UA1v3w074TefgwiLfRA.png" /></figure><p>Select ca.pem and click <strong>Next</strong>.</p><p>Ensure the option Place all certificates in the following store is selected.</p><p>Click Next and then Finish to complete the import.</p><p>Now you can proceed to connect your PostgreSQL to PowerBI.</p><p>a)Obtain Aiven connection details.</p><ul><li>Log in into your Aiven Console and navigate to your PostgreSQL service.</li><li>Find the connection Information section.</li><li>You will need the following details:</li><li><strong>Host/Server Name</strong></li><li><strong>Port</strong></li><li><strong>Database Name</strong></li><li><strong>Username</strong> and <strong>Password</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eRuxSfmwHbDuIp5e1iyPEg.png" /></figure><p>b)Configure Security and SSL.</p><p>.In Power BI desktop, navigate to file&gt;Options and settings&gt;Options.</p><ul><li>Under Global settings select security.</li><li>Scroll down to Data Extensions and ensure you allow extensions to load.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ch_d1fXmk-v-KnINrlDmrQ.png" /></figure><p>c)Connect via the PostgreSQL connector.</p><ul><li>Open Power BI click Get Data and choose PostgreSQL database.</li><li>Enter the Host and Database obtained from Aiven.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IXqx6sx_v8A8qpB1JDAeSw.png" /></figure><p>d)Authenticate and load data.</p><ul><li>Select the Database tab and enter the Aiven Username and Password.</li><li>Click connect.</li><li>You can now load or transform your data in Power BI.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f748e07b628b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Star vs. Snowflake: Dimensional Modeling for Power BI]]></title>
            <link>https://medium.com/@jlohreen/star-vs-snowflake-dimensional-modeling-for-power-bi-6de790c1fe17?source=rss-1aa9704fb219------2</link>
            <guid isPermaLink="false">https://medium.com/p/6de790c1fe17</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[snowflake-schema]]></category>
            <category><![CDATA[star-schema]]></category>
            <dc:creator><![CDATA[Joy Kyalo]]></dc:creator>
            <pubDate>Wed, 19 Nov 2025 17:20:14 GMT</pubDate>
            <atom:updated>2025-11-19T17:20:14.171Z</atom:updated>
            <content:encoded><![CDATA[<p>Dimensional modeling is the cornerstone of building efficient data warehouses and successful analytical solutions in Power BI. It structures data around two core concepts: <strong>Fact Tables</strong> (what you measure, e.g., Sales, Appointments) and <strong>Dimension Tables</strong> (how you describe it, e.g., Time, Product, Customer).</p><p>The two most common approaches to implementing this model are the Star Schema and the Snowflake Schema.</p><h3>1. The Star Schema (Denormalized)</h3><p>The Star Schema is the simplest and most widely used dimensional model. It is characterized by a central <strong>Fact Table</strong> directly connected to multiple, single-level <strong>Dimension Tables</strong>.</p><h4>Structure</h4><p>The dimension tables in a Star Schema are intentionally <strong>denormalized</strong>. This means that all attributes related to a dimension (e.g., Product Name, Category, Brand, Supplier Details) are stored in a single, wide table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1As2PlUHVryCnrHPm4KJiQ.png" /></figure><h4>When to Use (Star Schema)</h4><p>The Star Schema is best used when:</p><p><strong>-Query Performance is Critical:</strong> It is ideal for dashboards and self-service BI where users need very fast response times.</p><p><strong>-Simplicity is Key:</strong> The model is easier for non-technical users to understand and navigate.</p><p><strong>-Dimensions are Simple:</strong> The dimensions are relatively shallow and do not have complex, multi-level hierarchies.</p><p><strong>Advantages</strong></p><p>-Faster Query Speed: Requires fewer joins.</p><ul><li>Simpler to Understand: Intuitive structure for end-users and developers.</li><li>Optimized for OLAP: Highly compatible with OLAP cubes and time intelligence functions in DAX.</li></ul><p><strong>Disadvantages</strong></p><ul><li>Data Redundancy:<strong> </strong>Dimension attributes are duplicated.</li><li>Lower Data Integrity: Redundancy increases the risk of inconsistent attribute updates.</li><li>Higher Storage Consumption: Due to data redundancy.</li></ul><h3>2. The Snowflake Schema (Normalized)</h3><p>The Snowflake Schema is an extension of the Star Schema where the dimension tables are <strong>normalized</strong>. It appears complex because dimensions are broken down into multiple related sub-dimension tables, resembling a snowflake pattern.</p><h4>Structure</h4><p>Instead of having all details in one table, a Snowflake Schema might break it down:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*wTalppdt-GypOThO8myNIA.jpeg" /></figure><h4>When to Use (Snowflake Schema)</h4><p>The Snowflake Schema is appropriate when:</p><ul><li>Storage Efficiency is Vital: Ideal for very large datasets where reducing redundancy saves significant disk space and cost.</li><li>Dimensions are Highly Hierarchical: When dimensions have deep, multi-level relationships (e.g., a complex Organizational Chart or a deep Product Category structure).</li><li>Data Integrity is Paramount: Normalization ensures that an attribute (like a County name spelling) is only stored in one place, simplifying updates.</li></ul><p><strong>Advantages</strong></p><ul><li><strong>Reduced data redundancy:</strong> Normalizing dimensions minimizes data duplication.</li><li><strong>Improved data integrity:</strong> Less redundancy helps maintain consistency across the data.</li><li><strong>Efficient storage:</strong> Normalization leads to less storage space being used compared to a denormalized model.</li><li><strong>Flexible organization:</strong> It is well-suited for handling complex, hierarchical dimensions.</li></ul><p>Disadvantages</p><ul><li><strong>More complex design:</strong> Normalizing dimensions into multiple tables makes the schema more complex to build and understand.</li><li><strong>Slower query performance:</strong> Queries require more joins, which can make them slower to execute.</li><li><strong>More complex queries:</strong> The larger number of joins makes it more difficult for users to write and understand queries.</li><li><strong>Steeper learning curve:</strong> The complex structure can be challenging for new users or developers to grasp.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6de790c1fe17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Power BI and the Power of DAX]]></title>
            <link>https://medium.com/@jlohreen/power-bi-and-the-power-of-dax-fe2ae68a0b15?source=rss-1aa9704fb219------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe2ae68a0b15</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[dax-formula]]></category>
            <dc:creator><![CDATA[Joy Kyalo]]></dc:creator>
            <pubDate>Wed, 19 Nov 2025 17:12:43 GMT</pubDate>
            <atom:updated>2025-11-19T17:19:05.670Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Power BI: Transforming Data into Visual Stories</strong></h4><p>In today’s data-driven world, the ability to quickly translate vast datasets into understandable, interactive reports is paramount. This is where Microsoft Power BI excels. Power BI is not just a reporting tool; it is a unified, scalable platform for business intelligence (BI) that allows users to connect to virtually any data source, clean and transform that data (using Power Query), and visualize it through dynamic dashboards and reports.</p><p><strong>DAX: The Engine Behind the Insight</strong></p><p>While Power BI provides the interface, the engine that powers advanced, custom analytics is <strong>DAX (Data Analysis Expressions)</strong>. DAX is a formula language used across Microsoft’s BI stack. It is the language used to create new information from data already in your model, primarily through two objects:</p><ol><li><strong>Measures:</strong> Dynamic formulas that calculate aggregations (like sums or averages) , based on the filters applied by the user in the report (e.g., calculating Total Revenue for only the “Potato” crop).</li><li><strong>Calculated Columns:</strong> Formulas evaluated row-by-row and stored physically in the model, often used for categorization or segmenting data (e.g., assigning a “High Yield” status to a farm).</li></ol><p>DAX’s true strength lies in its context transition, allowing it to perform complex calculations that reference data across multiple tables, years, or categories — something traditional Excel formulas cannot easily replicate.</p><h4>DAX in Action: Analyzing the Kenya Crops Dataset</h4><p>Using a hypothetical <strong>Kenya Crops Dataset</strong> containing yields, planting dates, counties, and revenues, we can see how different DAX functions provide critical business metrics:</p><h4>1. Mathematical and Statistical Functions (Aggregation)</h4><p>These form the foundation for measuring performance and scale.</p><ul><li><strong>Total_Revenue = SUM(‘Crops’[Revenue (KES)])</strong></li><li>Calculates the grand total income from all crop sales across all regions, giving the overall financial scale of operations.</li><li><strong>Average_Yield_Per_Acre = AVERAGE(‘Crops’[Yield (Kg/Acre)])</strong></li><li>Determines the typical performance metric, helping benchmark whether a farm’s current yield is above or below the mean.</li></ul><p><strong>2. Text Functions</strong></p><p>Text functions help clean up or combine data fields for better readability and organization in reports.</p><ul><li><strong>County_Code = LEFT(‘Crops’[County], 3)</strong></li><li>Extracts the first three characters of the County name (e.g., “MOM” from “Mombasa”), creating a simplified code for dashboard labels</li><li><strong>Farm_Location = CONCATENATE(‘Crops’[Farm Name], “ — “, ‘Crops’[Crop Type])</strong></li><li>Combines descriptive columns into a single, comprehensive label (e.g., “Green Acres — Maize”), improving data readability in tables.</li></ul><h4>3. Date &amp; Time Functions</h4><p>These are vital for agricultural data, which is inherently seasonal and time-dependent.</p><ul><li><strong>Planting_Year = YEAR(‘Crops’[Planting Date])</strong></li><li>Simply extracts the numerical year, allowing easy slicing and filtering of data by planting cycle.</li><li><strong>Revenue_YTD = TOTALYTD(SUM(‘Crops’[Revenue (KES)]), ‘Date’[Date])</strong></li><li>Calculates the Year-To-Date cumulative revenue, tracking performance against an annual goal.</li><li><strong>Revenue_Last_Year = CALCULATE( [Total_Revenue], SAMEPERIODLASTYEAR(‘Date’[Date]) )</strong></li></ul><p>This measure uses SAMEPERIOBLASTYEAR to shift the current date filter context back by exactly one year, allowing for an immediate Year-over-Year<strong> </strong>comparison of revenue performance.</p><h4>4. Logical Functions</h4><p>Logical functions introduce decision-making logic into the calculations, allowing for automated classification.</p><ul><li><strong>Yield_Status = IF( ‘Crops’[Yield (Kg/Acre)] &gt; [Average_Yield_Per_Acre] * 1.2, “High Yield”, “Standard”)</strong></li><li>Uses an IF statement to categorize yields that are 20% higher than the average as &quot;High Yield,&quot; helping quickly identify top-performing farms.</li><li><strong>Season_Category = SWITCH(TRUE(), ‘Crops’[Month Number] IN {1,2,3}, “Q1-Dry”, ‘Crops’[Month Number] IN {4,5,6}, “Q2-Rainy”, “Other”)</strong></li><li>The SWITCH function evaluates the month number against multiple conditions, automatically assigning a predefined season category, which is far cleaner than nested IF statements.</li></ul><h4>Conclusion: From Data to Growth</h4><p>The combination of Power BI’s intuitive visualization and DAX’s analytical depth empowers businesses and farmers to make decisions based on precise facts, not intuition.</p><p>A farmer can use DAX functions like sameperiodlastyear to see if their new fertilizer increased potato yield compared to the previous cycle. A large agribusiness can use totalyield to track regional sales targets and use the if function to flag underperforming counties instantly. This move from descriptive reporting (&quot;What happened?&quot;) to diagnostic analysis (&quot;Why did it happen?&quot;) is invaluable.</p><p>Personal Insight: In my view, the real value of Power BI and DAX is not just in the complex formulas, but in the democratization of insights. They take complex analytical models and wrap them in a simple, visual layer, making data literacy accessible. For agricultural economies, this means better resource allocation, higher yields, and more resilient businesses. It transforms complex data into a clear path toward sustainable growth.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe2ae68a0b15" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>