<?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 Sefiat Adedeji on Medium]]></title>
        <description><![CDATA[Stories by Sefiat Adedeji on Medium]]></description>
        <link>https://medium.com/@adedeji_s?source=rss-954791611315------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pH46Ve_GgTJeVcCS1NCYTw.jpeg</url>
            <title>Stories by Sefiat Adedeji on Medium</title>
            <link>https://medium.com/@adedeji_s?source=rss-954791611315------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 18:03:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adedeji_s/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[Getting Data from Different Sources in Power BI]]></title>
            <link>https://medium.com/@adedeji_s/getting-data-from-different-sources-in-power-bi-49f354c637a6?source=rss-954791611315------2</link>
            <guid isPermaLink="false">https://medium.com/p/49f354c637a6</guid>
            <category><![CDATA[sharepoint]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[excel]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Sefiat Adedeji]]></dc:creator>
            <pubDate>Wed, 08 Apr 2026 07:50:33 GMT</pubDate>
            <atom:updated>2026-04-08T07:50:33.550Z</atom:updated>
            <content:encoded><![CDATA[<p>A beginner-friendly, no-fluff guide to connecting Power BI to multiple data sources</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-8E6qEaqGf2vuAZb2BhVA.png" /></figure><p>Power BI isn’t just a visualization tool, it’s a <strong>data integration engine</strong>. Most people open Power BI for the first time, head straight for the visuals, and wonder why their dashboard doesn’t look right. The reason is almost always the same: they skipped the foundation. And the foundation in Power BI is <strong>data…</strong>specifically, knowing how to connect to it, preview it, and understand what you’re working with before you build anything.</p><p>Here’s the reality of working as a data analyst: your data is never in one place. Finance keeps figures in Excel. Operations exports CSVs. IT manages a proper database. A manager sends a PDF with numbers in it. A team uploads files to SharePoint every month. Your job is to pull all of that together into one coherent, trustworthy report.<br> <br>Power BI was designed for exactly that. In this guide, I’ll walk you through how this works in a <strong>clear, practical, beginner-friendly way</strong>, so even if you’re just starting out, you can follow along confidently.</p><p><strong>Objectives</strong></p><blockquote><em>Understand how Power BI handles data from multiple sources through its architecture</em></blockquote><blockquote><em>Connect Power BI to different source types: Excel, CSV, PDF, JSON, SharePoint, SQL databases, Web, and Azure</em></blockquote><blockquote><em>Learn what to review and validate in Power Query before loading data into the model</em></blockquote><blockquote><em>Build the habit of treating data ingestion as a critical step, not a formality</em></blockquote><p><strong>Process Overview</strong></p><p>Here’s how we’ll approach this:</p><ol><li><strong>Data IntegrationArchitecture :</strong> Understanding the flow of data in Power BI before touching any source.</li><li><strong>Connecting to Each Data Source:</strong> Step-by-step for Excel, CSV, PDF, MySQL, SQL Server, JSON, SharePoint, Web, and Azure Analysis Services</li><li><strong>Power Query Validation</strong>: What to check before loading your data into the model</li><li><strong>Insights and Best Practices:</strong> Key takeaways to carry into every project.</li></ol><h4>1. Data Integration Architecture</h4><p>Before connecting to anything, it’s worth understanding what actually happens when you bring data into Power BI. The process is not as simple as “click, import, done.”<br>Every data source you connect to passes through <strong>Power Query. </strong>Power BI’s built-in data transformation engine. Think of Power Query as the preparation room. Your data enters here first, where you can preview its structure, catch problems, rename columns, fix data types, and shape it into something clean before it ever touches your data model.</p><p>The flow looks like this:</p><pre>Data Source (Excel / CSV / SQL / PDF / JSON / Web etc.)<br>                        ↓<br>              Get Data Connector<br>                        ↓<br>           Power Query Editor<br>      (preview → validate → transform)<br>                        ↓<br>              Data Model (loaded)<br>                        ↓<br>          Reports and Dashboards</pre><p>This architecture is important because every decision you make in Power Query flows downstream into your model and ultimately into every visual in your report. Skipping or rushing through this stage is where most reporting errors are born.</p><h4>2. Connecting to Each Data Source</h4><p><strong>2.1 Excel Workbook</strong></p><p>Excel is probably the most common data source analysts work with, so this is a great place to start.<br> From the Home tab in Power BI Desktop, click <strong>Get Data</strong>, then select E<strong>xcel Workbook</strong>. Browse to your file and open it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vTKsfsWC5_GpaIcTZU-hxQ.png" /></figure><p>Browse to the file location and open it. You’ll notice that only Excel files are displayed, making it easier to select the correct file format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jCgDCOXNPg2B4X5mvwBgnA.png" /></figure><p>A window called the <strong>Navigator</strong> will appear. This is where Power BI shows you everything it found inside your Excel file, all the sheets and any named tables. You can tick the ones you want and preview them on the right before deciding what to bring in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYz-mvdROQwCMfH3gz8vpA.png" /></figure><p>Once you’ve selected what you need, you have two options: <strong>Load </strong>or <strong>Transform</strong> Data.<br><strong>Load:</strong> pulls the data in as-is, immediately.</p><p><strong>Transform Data:</strong> opens Power Query so you can review and clean the data first.<br>Unless your data is already perfectly structured (spoiler: it rarely is), always choose <strong>Transform Data.</strong> It’s the safer move.</p><p><strong>2.2 Connecting to a CSV or Text File</strong></p><p>CSV files are straightforward, no formatting, just rows of data separated by a delimiter. That simplicity makes them reliable.<br>Navigate to <strong>Home → Get Data → Text/CSV, </strong>locate your file, and open it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VsYQOBPUaoBE6CcKcv_AqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lB7OS9e6SakiJDzbWhmidA.png" /></figure><p>Power BI displays a preview dialog immediately, showing the detected delimiter (usually a comma), column headers, and a sample of the rows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZWL8OyKqVLefQRO23BR9qg.png" /></figure><p>Power BI also supports other separator types, including semicolons, spaces, tabs, and custom characters. Once you’ve selected the correct delimiter for your file, you’ll see two options: <strong>Load</strong> and <strong>Transform Data</strong>.</p><p>While you <em>can</em> click Load to import the data directly, <strong>Transform Data is the recommended option</strong>. This opens the Power Query Editor, giving you the opportunity to inspect, clean, and shape your data before it lands in your report - saving you a lot of headaches down the line.</p><p><strong>2.3 Connecting to a PDF</strong><br> <br> This one surprises most people when they first discover it - Power BI can extract tables directly from PDF files.<br>Navigate to <strong>Home → Get Data → More</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*82yAopXt70ru5wCHYcYG3w.png" /></figure><p>A dialog box will appear - select <strong>All</strong>, then select <strong>PDF </strong>and click <strong>Connect</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zuOgiXQULoGvC6nhgo4pcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBYhjZRrLACwoIFCvYPSSQ.png" /></figure><p>select your file, and give Power BI a moment to scan the document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNKJbxzQnCNYNjq47TDD2w.png" /><figcaption>Preview of the file selected in pdf</figcaption></figure><p>It will detect any tables it finds and list them in the Navigator. These are usually named things like “Table001 (Page 1)” or “Page001.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oFzZGLf-oMfwS5otsXeUPw.png" /></figure><p>Click through each detected table and preview it until you find the data you need. The quality of the extraction depends entirely on the original file. If the PDF was created digitally, exported from Excel, Word, or a reporting system, the extraction is usually clean. If it’s a scanned document (essentially a photograph saved as PDF), Power BI cannot read it. You would need an OCR tool to convert it first.<br>Once you’ve identified the correct table, click <strong>Transform Data</strong> to review it in Power Query.</p><p><strong>2.4 Connecting to a Database (MySQL and SQL Server)</strong></p><p>Power BI supports connections to a wide range of databases - Oracle, SAP, IBM DB2, Amazon Redshift, Snowflake, and many more. But in practice, the three you’ll encounter most often as a data analyst are <strong>MySQL</strong>, <strong>SQL Server</strong>. Those are the ones we’ll focus on here.</p><p>The reason databases matter is scale. Excel files and CSVs work well up to a point, but databases are where organisations store millions of records in properly structured, relational systems. Connecting Power BI directly to a database means you’re working with the most complete, up-to-date version of the data, not a static export someone pulled last Tuesday.</p><p>Before you connect to any database, have these three things ready: the <strong>server name or IP address</strong>, the <strong>database name</strong>, and your <strong>login credentials</strong>. If you don’t have them, your IT team or database administrator can provide them.</p><p><strong>2.4.1 MySQL</strong></p><p>Navigate to <strong>Home → Get Data → More.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*82yAopXt70ru5wCHYcYG3w.png" /></figure><p>A dialog box will appear - select <strong>Database</strong> or <strong>All,</strong> then select <strong>MySQL database</strong> and click <strong>Connect</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_INVgv9-gGeMCQHFCDTuKQ.png" /></figure><p>In the dialog that appears, enter the server name and the database name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_g9eudrT8MhOHFsbDkLHww.png" /></figure><p>To get your Sever name on <strong>MySQL Workbench</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q87ABhwMM4_yB-cmnB7KCw.png" /></figure><p>For your database name, navigate to the <strong>SCHEMAS</strong> section and write the database name exactly as it appears there. In this example, we will be using the <strong>world</strong> database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWQ2soSM8NzribUlooyMng.png" /></figure><p>For a first timer, at times it may require you to provide some authentications credentials click on Database and Provide your authentication credentials, which is <strong>root</strong> and your password then click OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TQov6tLXLd00XVWl9Cr2VQ.png" /></figure><p>The Navigator will open showing all the tables inside that <strong>database</strong>. Select the ones you need and click <strong>Transform Data</strong> to review them in Power Query before loading.</p><p><strong>2.4.2 SQL Server</strong></p><p>Navigate to <strong>Home → Get Data → SQL Server</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uVzKINUKW-PHgox9zIaqKw.png" /></figure><p>The connection dialog will open, and it has more to it than it first appears, so let’s walk through each field properly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Anr1Uc9RPaAdAqTnePV6w.png" /></figure><p><strong>Server</strong> is where you enter the server name or IP address. This might be something like localhost if you&#39;re working on your own machine, or a full network path in an organisational environment.</p><p><strong>Database (optional)</strong> is exactly what it says - optional. You can leave this blank and Power BI will show you all available databases once you connect, or you can type the name directly if you already know which one you need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LIh4GnmuL0U4OX-jb7BXxw.png" /><figcaption><strong>This is where to locate your server name on SQL Server</strong></figcaption></figure><p>To locate your database name, go to the <strong>Object Explorer</strong> in<strong> SQL Server.</strong> There, you’ll find the list of available databases, simply identify the one you want and type its name exactly as it appears.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BKybpSdNronGb85CNifsiA.png" /></figure><p>The Navigator will open showing all available tables in the database. Select what you need and click <strong>Transform Data</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8UnEqgRUIZsCcDM3FMkcsw.png" /></figure><p><strong>Data Connectivity Mode</strong> is where a lot of beginners click past without reading - but it’s worth pausing here because your choice affects how the entire report behaves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_8AODAdXwdOfXWuuoJXaKw.png" /></figure><ol><li><strong>Import</strong> is the default option. Power BI pulls a copy of your data from the database and stores it inside the Power BI file. Your report works from that local copy, which makes it fast and responsive. The trade-off is that the data is only as fresh as the last time you refreshed, it does not update automatically in real time.</li><li><strong>DirectQuery</strong> works differently. Power BI does not store a copy of the data. Instead, every time you interact with a visual - filtering, drilling down, clicking a slicer, Power BI sends a live query directly to the database and returns the result in that moment. This means your report always reflects the current state of the data. The trade-off is that performance depends on the speed of the database, and some Power BI features are limited in this mode.</li><li><strong>Advanced Options</strong> is a collapsible section at the bottom of the dialog. Most of the time you won’t need to touch it, but there is one option inside that is genuinely useful, a text box where you can write a native SQL query instead of selecting a full table.</li></ol><p>As a general rule: use <strong>Import</strong> when your data doesn’t change by the minute and you need the best performance. Use <strong>DirectQuery</strong> when real-time accuracy matters more than speed - for example, a live operational dashboard where data is updated throughout the day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EncVTytJjuWgeupcqYqsnw.png" /></figure><p>We only need five columns from the <strong>SalesLT.Customer</strong> table in the <strong>AdventureWorks2019</strong> database. In this case, the best approach is to use <strong>DirectQuery</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0E-Cl0E66L2ht7v_31jLCQ.png" /></figure><p>This is particularly useful when working with large tables. Instead of importing 2 million rows and filtering them in Power Query, you write a query that filters, joins, and aggregates the data at the database level - so only the rows and columns you actually need ever reach Power BI. If you’re already comfortable with SQL, this is almost always the more efficient approach. It keeps your model lean, reduces file size, and makes your report noticeably faster.</p><p>Once you’ve filled in your details, click <strong>OK</strong> and choose your authentication method, typically Windows credentials in a workplace environment, or a SQL Server username and password. The Navigator will open showing all available tables. Select what you need and click <strong>Transform Data</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9QVxxmVW7rGrkHxNXrosUg.png" /></figure><p><strong>2.5 Connecting to a JSON File</strong><br>JSON is the format you’ll encounter when pulling data from APIs or working with developer-exported datasets. Unlike a spreadsheet, JSON stores data in a nested, hierarchical structure - which means it doesn’t arrive looking like a table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q4QyYGhKBuIZoDuUHW3rgA.png" /><figcaption>JSON file</figcaption></figure><p>Navigate to <strong>Home → Get Data → More</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*82yAopXt70ru5wCHYcYG3w.png" /></figure><p>A dialog box will appear - select <strong>All</strong>, then select <strong>JSON</strong> and click <strong>Connect</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xjl5p3T56zX4aSA56DGwiA.png" /></figure><p>select your file, and Power BI loads it into Power Query Direct.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qi052_9WnJaOgyBAdnWn5w.png" /></figure><p>What you’ll typically see first is a single column labelled <strong>List </strong>or <strong>Record</strong> with small expand icons (arrows) next to each entry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nz-4eoPvyHwM9ToIpHh49g.png" /></figure><p>Depending on how deeply nested your JSON is, you may need to expand two or three times before you have a flat, usable table.<br>Do not rush this step. Take your time expanding each layer and checking that the resulting columns make sense before close and apply to power bi desktop.<br> <br><strong> 2.6 Connecting to a SharePoint Folder</strong><br>This feature is particularly useful in team environments where multiple people are regularly uploading files to a shared SharePoint location. Instead of connecting to each file individually, you connect to the entire folder and Power BI reads everything inside it.<br> <br>Navigate to <strong>Home → Get Data → More → All → SharePoint Folder.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HrxzVbGgRLD6_4ULGbZ7Eg.png" /></figure><p>Paste in the root URL of your SharePoint site (not the specific folder - just the site, like `https://yourorganisation.sharepoint.com/sites/yoursite`). Click OK and sign in with your Microsoft credentials when prompted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*TPv-ebmmOg9alzLUbOU9rw.png" /></figure><p>Power BI will return a list of all files it found in that SharePoint location…file names, types, sizes, and dates modified. From here, click <strong>Combine &amp; Transform Data</strong> to merge the contents of those files into a single unified table.<br><strong>Important</strong>: All files being combined must have the same structure - identical column names and the same column order. If one file has an extra column or a differently named header, the combination will either produce errors or a messy result. Consistency in the source files is what makes this feature work reliably.<br> <br><br><strong> 2.7 Web Data</strong><br>Power BI can connect directly to a web page and extract tables from it. This is useful for publicly available datasets - government statistics, published reports, exchange rate tables, or any structured data that lives on a public web page.<br>Navigate to <strong>Home → Get Data → Web</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vd1zTpBTConO87SAWNI-ow.png" /></figure><p>When connecting to a web data source in Power BI, you’ll notice two options at the top of the dialog box, <strong>Basic</strong> and <strong>Advanced</strong>. <strong>Basic</strong> is straightforward,you simply paste your URL and click OK. This is the option you’ll use most of the time for standard web pages and public data sources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j756e0Fb45KaSHzIhbuFhA.png" /></figure><p><strong>Advanced</strong> gives you more control over how Power BI connects to the web. Here’s what each field does:</p><p><strong>URL:</strong> This is the same URL you’d enter in Basic mode, but in Advanced mode it’s broken into parts, allowing you to add URL parameters in separate lines and build a more complex URL if needed.</p><p><strong>Command Timeout: </strong>This sets how long Power BI should wait for the web source to respond before giving up. If you’re connecting to a slow or large data source, you can increase this value to prevent the connection from timing out too early.</p><p><strong>HTTP Request Header Parameters: </strong>This is where you can pass additional information along with your request, such as an API key, content type, or authorisation token. This is particularly useful when connecting to web APIs that require authentication headers to return data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W3Tzc9lOy7JteQloCBkUkg.png" /></figure><p>We’ll be using the <strong>Basic</strong> option here. After pasting your URL, select your preferred authentication method, either <strong>Anonymous</strong> or <strong>Windows</strong> and then click <strong>Connect</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BbmxD9VZD__lDUr3tCnKIQ.png" /></figure><p>Power BI loads the page and detects any tables it can find. In the Navigator, each detected table is listed separately. Preview them to find the one that matches what you need, then click <strong>Transform Data.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5fG0puwFRadJn4L5E7aTQ.png" /></figure><p>This works best on pages with clean, static HTML tables. Pages that load data dynamically through JavaScript may not return the results you expect through this connector.<br> <br><strong> 2.8 Azure Analysis Services</strong><br>For organisations using Azure Analysis Services as a central data platform, Power BI can connect to it as a <strong>live connection</strong> - meaning data stays in Analysis Services and Power BI queries it in real time, rather than importing a local copy.<br> <br>Navigate to <strong>Home → Get Data → More →Azure → Azure Analysis Services.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6DUAREOVpZMJzJDTn-ksOw.png" /></figure><p>Enter the server name (available from your Azure portal or data team), select the database or model, and choose <strong>Connect live</strong> as the connection mode. Click <strong>OK</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LImfRNBMGhQ9gRBl4wFkAg.png" /></figure><p>With a live connection, your report always reflects the current state of the data - no manual refresh needed. The trade-off is that you work within the structure defined in Analysis Services. You won’t have the same flexibility to reshape data in Power Query as you would with an import connection.</p><h4><strong>3. Power Query Validation - What to Check Before Loading.</strong></h4><p>Getting connected is only the beginning. Before clicking <strong>Close &amp; Apply</strong> in Power Query, there are several things worth checking on every dataset, regardless of the source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*myuFmRpXsfZKzoUn8bVsZw.png" /><figcaption>preview of a power query editor</figcaption></figure><blockquote><strong>Column headers:</strong> Are they clear, meaningful names? If any column is labelled “Column1,” “F3,” or carries a system-generated name, rename it to something your future self will understand.</blockquote><blockquote><strong>Data types:</strong> Check the type icon at the top of every column. Dates should be Date type. Numbers should be whole number or decimal as appropriate. Text should be text. Incorrect data types will cause calculation errors and broken visuals later in your report.</blockquote><blockquote><strong>Null and blank values:</strong> They’re not always a problem, but you should know where they exist and make a deliberate decision — fill them, remove the affected rows, or leave them depending on the context.<br> <br><strong>Unnecessary columns</strong>: If a table has 40 columns and your report only uses 10, remove the other 30. Keeping unused columns increases file size and slows performance.</blockquote><blockquote><strong>Row counts</strong>: Always sense-check the numbers. If you expected 5,000 rows and Power Query is showing 500,000, something went wrong - possibly a join that created unintended duplicates. If you expected 10,000 rows and you’re seeing 9,200, there may be missing records worth investigating before loading.</blockquote><p>Turn on <strong>Column Quality</strong> from the <strong>View tab </strong>inside Power Query. It adds a bar above each column showing the percentage of valid, empty, and error values at a glance. It is one of the fastest ways to catch data quality problems before they make it into your report.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cL3PinpnQ9pbalg192SmXQ.png" /></figure><h4><strong>4. Insights and Best Practices</strong></h4><p>After working through all these connection types, here are the key takeaways:<br><strong>Data rarely lives in one place.</strong> In real analytics work, combining multiple sources is the norm, not the exception. Getting comfortable with each connector type is a skill that will serve you in almost every project.</p><p><strong>Transform Data, always.</strong> Clicking Load without reviewing your data in Power Query is the equivalent of publishing a report without proofreading it. Always open Power Query first.</p><p><strong>The data types matter more than most beginners expect.</strong> A date stored as text won’t work in time intelligence calculations. A number stored as text won’t aggregate correctly. These are the kinds of issues that produce errors six steps later when you’ve forgotten where the data came from.<br> <br><strong>Performance starts at the source</strong>. Importing only the columns and rows you actually need - especially when working with SQL databases - keeps your model lean and your report fast.</p><p><strong>Consistency in source files enables automation.</strong> The SharePoint Folder connector is a good example of this. When source files are consistently structured, Power BI can automate the combination and refresh. When they’re inconsistent, every new file becomes a manual problem to solve.</p><h4>Conclusion</h4><p>The connection step in Power BI is where every report begins and more often than not, it’s where the problems in a report also begin. Understanding not just <strong>how</strong> to connect to a source, but <strong>what to look for</strong> once you’re connected, is what separates a report people trust from one that gets questioned in every meeting.<br> <br>The visuals are the part everyone sees. But the data behind them is the part that makes or breaks everything.</p><p>I trust you found value in this post. If you have questions about any of the connectors or run into something unexpected in Power Query, drop a comment. I read every single one. Your thoughts matter, so don’t hesitate to drop a comment for any questions or feedback. And if this helped you, share it with someone who’s just getting started with Power BI. We all needed a guide like this at some point.</p><p><strong>Here’s to building reports people can actually rely on.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49f354c637a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pizza Sales Analysis Using MS SQL]]></title>
            <link>https://medium.com/@adedeji_s/pizza-sales-analysis-using-ms-sql-b75193f50d31?source=rss-954791611315------2</link>
            <guid isPermaLink="false">https://medium.com/p/b75193f50d31</guid>
            <dc:creator><![CDATA[Sefiat Adedeji]]></dc:creator>
            <pubDate>Mon, 13 May 2024 08:02:57 GMT</pubDate>
            <atom:updated>2024-05-13T08:02:57.317Z</atom:updated>
            <content:encoded><![CDATA[<p>Research into the intricate world of pizza sales with our detailed analysis, unveiling key trends and consumer preferences. From scrutinizing sales data to understanding customer behavior, embark on a flavorful exploration of the pizza market’s dynamics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*IkNQZOQKCt4GpToAF2HXgQ.jpeg" /></figure><h4>Introduction</h4><p>You’ve been hired as a BI consultant a Greek-inspired pizza place in New Jersey, your role is to help the restaurant use data to improve operations, and just received the following note:</p><p>Welcome aboard, we’re glad you’re here to help!</p><p>Things are going OK here at Plato’s, but there’s room for improvement. We’ve been collecting transactional data for the past year, but really haven’t been able to put it to good use. Hoping you can analyze the data and put together a report to help us find opportunities to drive more sales and work more efficiently.</p><p>Here are some questions that we’d like to be able to answer:</p><p><strong>Business Problem</strong></p><blockquote>What days and times do we tend to be busiest?</blockquote><blockquote>How many pizzas are we making during peak periods?</blockquote><blockquote>What are our best and worst-selling pizzas?</blockquote><blockquote>What’s our average order value?</blockquote><h4>1. Data Collection and Acquisition</h4><p><strong>1. 1 Data Source and Structure</strong></p><p>I got this dataset from <a href="https://www.kaggle.com/datasets/shilongzhuang/pizza-sales/data"><strong>Kaggle</strong></a>, the data contains the 12 columns namely; order_id, order_details_id, pizza_id, quantity, order_date, order_time, unit_price, total_price, pizza_size, pizza_category, pizza_ingredients, pizza_name.</p><p><strong>1.2 Tool</strong></p><p>We’ll utilize <strong>Microsoft SQL Server(MS SQL Server)</strong> as our primary data tool for the process of data cleaning, analysis and <strong>PowerBI</strong> for visualization.</p><p><strong>1.3 Data Dictionary</strong></p><p>The data dictionary speaks extensively on the meaning of the dataset and what it entails. This pizza sales dataset make up 12 relevant features:</p><ul><li>order_id: Unique identifier for each order placed by a table</li><li>order_details_id: Unique identifier for each pizza placed within each order (pizzas of the same type and size are kept in the same row, and the quantity increases)</li><li>pizza_id: Unique key identifier that ties the pizza ordered to its details, like size and price</li><li>quantity: Quantity ordered for each pizza of the same type and size</li><li>order_date: Date the order was placed (entered into the system prior to cooking &amp; serving)</li><li>order_time: Time the order was placed (entered into the system prior to cooking &amp; serving)</li><li>unit_price: Price of the pizza in USD</li><li>total_price: unit_price * quantity</li><li>pizza_size: Size of the pizza (Small, Medium, Large, X Large, or XX Large)</li><li>pizza_category: Unique key identifier that ties the pizza ordered to its details, like size and price</li><li>pizza_ingredients: ingredients used in the pizza as shown in the menu (they all include Mozzarella Cheese, even if not specified; and they all include Tomato Sauce, unless another sauce is specified)</li><li>pizza_name: Name of the pizza as shown in the menu</li></ul><h4>2. Data Preparation</h4><p><strong>Creating a database, setting up tables, and importing our dataset.</strong></p><p>Let’s navigate to our MS SQL, where we’ll create a database. Simply right-click on the databases and select New Database, name it as “pizza” then select OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*ysYQsJkOgQEo6jmSskL4LQ.png" /></figure><p><strong>For data importation:</strong> Right-click on the newly created Database called “pizza”, then select “Tasks”, and then click on “Import Flat File”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*35RPCty_WCzm9611kpCGPw.png" /></figure><p>Navigate to the directory where your file is stored and select it to begin the import process. Provide a descriptive table name for your file; let’s name it “pizza sales”. This step ensures that the imported data is organized into a table within the database, making it easier to manage and analyze.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*ylJCd41bitdU2OHqAxFaSg.png" /></figure><p>Review the data to get a glimpse of how our table will appear once imported. This step allows us to ensure that the data is formatted correctly and meets our expectations before finalizing the import process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*H_JvyeojrviNQ6rUwhz43A.png" /></figure><p>Inspect the columns to determine if any adjustments are required, such as changing data types or allowing null values. In this case, it appears that no modifications are necessary as the current settings meet our requirements. Additionally, since we are working with a single table, there is no need to designate a primary key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*hCYhY2KGUJ09d9PIDe5N7w.png" /></figure><p>Click on Next to see the summary then finish.</p><p><strong>3. Data Cleaning and Transformation</strong></p><p><strong>3.1 Data Cleaning</strong></p><p><strong>Observe our dataset.</strong></p><p>Check the first 10 rows to make sure it imported well.</p><pre>SELECT TOP 10 *<br>FROM pizza_sales</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G6gHXZYMyrFKHe2fXzQJiQ.png" /><figcaption>first 10 rows</figcaption></figure><p>Reviewing the first 10 rows of data without encountering any errors indicates successful importation and suggests that our data was imported accurately. This initial validation step confirms the integrity of the imported data and ensures that further analysis can proceed smoothly</p><p>Total rows in our dataset</p><pre>SELECT COUNT(*) AS number_of_rows <br>FROM  pizza_sales</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*q-f6xS_Com-IuiFznvWpOA.png" /><figcaption>Number of rows</figcaption></figure><p>Our pizza sales dataset comprises a total of 48,620 rows.</p><p><strong>Checking for missing values.</strong></p><pre>SELECT *<br>FROM pizza_sales<br>WHERE order_details_id IS NULL OR order_id IS NULL OR pizza_id IS NULL OR pizza_category IS NULL <br>OR pizza_ingredients IS NULL OR pizza_name IS NULL</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*RY31L_HIqpTyr2EGUa7ljA.png" /></figure><p>Upon review, our analysis indicated blank results, signifying the absence of missing values within our dataset. This reassures us of the completeness and reliability of our data.</p><p><strong>Checking for duplicates</strong></p><pre>SELECT order_details_id, COUNT(order_details_id) as COUNT<br>FROM pizza_sales<br>GROUP BY order_details_id<br>HAVING COUNT(order_details_id)&gt;1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*I5OunURKVu8GoV_pRwpwTw.png" /></figure><p>The query returns an empty table, showing there are no duplicate rows.</p><p><strong>3.2 Data Transformation</strong></p><p>Pizza sizes represented as S, M, L, X, XL, XXL in the pizza_size column were changed to Small, Medium, Large, XLarge, XXLarge with the Replace function</p><pre>UPDATE pizza_sales<br>SET pizza_size = REPLACE(REPLACE(REPLACE(pizza_size, &#39;S&#39;, &#39;Small&#39;), &#39;M&#39;, &#39;Medium&#39;), &#39;L&#39;, &#39;Large&#39;)<br>WHERE pizza_size IN (&#39;S&#39;, &#39;M&#39;, &#39;L&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*1sZPfMnswyi-oi0KnXyf9A.png" /></figure><pre>SELECT DISTINCT pizza_size<br>FROM pizza_sales</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/173/1*4mKdvnPZBqStqGesVAgSCA.png" /></figure><h4>4. Exploratory Data Analysis (EDA)</h4><p>Business Problem</p><ol><li><strong>What days and times do we tend to be busiest?</strong></li></ol><p>To provide insight into busiest days and times, I conducted two distinct queries to showcase weekdays and hours separately. This approach aims to offer a clear visualization of when the establishment experiences the highest levels of activity, aiding the owner in optimizing staffing schedules and resource allocation strategies.</p><p>I utilized the “DATENAME” function to extract the day from the order_date column, enabling me to discern the distribution of orders throughout the week. Subsequently, I computed the total number of orders and calculated the average number of orders per day by dividing the total number of orders by the number of days. This information was grouped by the day of the week and ordered based on the count of orders. Below are the queries I employed for this analysis:</p><pre>SELECT DATENAME(WEEKDAY, order_date) AS day_of_week, COUNT(distinct(order_id)) AS Total_order,<br>ROUND((COUNT( DISTINCT order_id)/COUNT(DISTINCT order_date)),0) AS Average_daily_order<br>FROM pizza_sales<br>GROUP BY DATENAME(WEEKDAY, order_date)<br>ORDER BY 2 DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*DEp_DP7wddrxmYLoZ3flMQ.png" /><figcaption>Day of week with their total order and average daily order</figcaption></figure><p>Throughout the year, Friday emerges as the busiest day of the week, with the business recording the highest pizza sales on Fridays. Friday witnessed a total of 3538 orders filled, averaging 70 orders per day. This is followed by Thursday and Saturday, with total orders of 3239 and 3158, and average daily orders of 62 and 60, respectively.</p><p>To extract only the hour from the order_time column, I utilized the “FORMAT” function in conjunction with the “IIF” function to display the time in either AM or PM format. Subsequently, I employed the “CONCAT” function to combine the two elements. Below is the query utilized for this purpose:</p><pre>SELECT <br>    CONCAT(<br>        FORMAT((DATEPART(HOUR, order_time) + 11) % 12 + 1, &#39;00&#39;), <br>        &#39; &#39;,<br>        IIF(DATEPART(HOUR, order_time) &lt; 12, &#39;AM&#39;, &#39;PM&#39;)<br>    ) AS hours, <br>    COUNT(DISTINCT order_id) AS Total_order<br>FROM <br>    pizza_sales<br>GROUP BY <br>    CONCAT(<br>        FORMAT((DATEPART(HOUR, order_time) + 11) % 12 + 1, &#39;00&#39;), <br>        &#39; &#39;,<br>        IIF(DATEPART(HOUR, order_time) &lt; 12, &#39;AM&#39;, &#39;PM&#39;)<br>    )<br>ORDER BY <br>    Total_order DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*29vZtEv31-1LM69fozU8wA.png" /><figcaption>Result for time and the total number of orders.</figcaption></figure><p>The busiest times for pizza orders are typically around “12pm”, “1pm”, “5pm”, “6pm”, and “7pm”, indicating that the business experiences its highest order volumes during lunch and dinner hours.</p><p>Moreover, I took the initiative to identify the busiest month for orders, despite not being specifically requested. This additional analysis will provide valuable insights for our dashboard.</p><pre>SELECT DATENAME(Month, order_date) AS Month, COUNT(distinct(order_id)) AS Total_order<br>FROM pizza_sales<br>GROUP BY DATENAME(Month, order_date)<br>ORDER BY 2 DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/1*QV38VGtsGfvFdr3v1hAwpQ.png" /><figcaption>Month with Total order</figcaption></figure><p>July stands out as the month with the highest number of orders, totaling 1935.</p><p><strong>2. How many pizzas are we making during peak periods?</strong></p><p>I’ll be employing a similar code as before to determine the busiest hours, with a slight tweak: this time, we’ll be focusing on the top 3 busiest hours, representing our peak periods. Since we’re interested in the quantity we’re producing, we’ll utilize the “SUM” function to calculate the quantity column. Below is the query utilized:</p><pre>SELECT <br>    CONCAT(<br>        FORMAT((DATEPART(HOUR, order_time) + 11) % 12 + 1, &#39;00&#39;), <br>        &#39; &#39;,<br>        IIF(DATEPART(HOUR, order_time) &lt; 12, &#39;AM&#39;, &#39;PM&#39;)<br>    ) AS hours, <br> SUM(quantity) AS Number_of_pizza_sold,<br>    SUM(quantity)/COUNT(DISTINCT order_date) AS Average_Pizza_made<br>FROM <br>    pizza_sales<br>WHERE <br>CONCAT(<br>        FORMAT((DATEPART(HOUR, order_time) + 11) % 12 + 1, &#39;00&#39;), <br>        &#39; &#39;,<br>        IIF(DATEPART(HOUR, order_time) &lt; 12, &#39;AM&#39;, &#39;PM&#39;)<br>    ) IN (&#39;12 PM&#39;, &#39;01 PM&#39;, &#39;06 PM&#39;)<br>GROUP BY <br>    CONCAT(<br>        FORMAT((DATEPART(HOUR, order_time) + 11) % 12 + 1, &#39;00&#39;), <br>        &#39; &#39;,<br>        IIF(DATEPART(HOUR, order_time) &lt; 12, &#39;AM&#39;, &#39;PM&#39;)<br>    )<br>ORDER BY 2 DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*axSJcqnC4wkMACdbRKEVHg.png" /></figure><p>During the peak periods of 12pm, 1pm, and 6pm, an average of 18, 17, and 15 pizzas were prepared, respectively. These periods generated significant revenue, with amounts totaling $6776, $6413, and $5417 in the top three peak periods.</p><p><strong>3. What are our best and worst-selling pizzas?</strong></p><p>To address this query, I’ll utilize the “SUM” function to compute the quantity of pizzas sold, along with the “TOP” clause to restrict the results. Additionally, I’ll employ the “GROUP BY” statement to group data by pizza name, and the “ORDER BY” statement with the “DESC” feature to obtain the top and bottom three results.</p><pre>SELECT TOP 3 (pizza_name), SUM (quantity) AS pizza_sold<br>FROM pizza_sales<br>GROUP BY (pizza_name)<br>ORDER BY 2 DESC</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*99qfux_OZ93StuGqG74XaA.png" /><figcaption>Best selling pizza</figcaption></figure><pre>SELECT TOP 3 (pizza_name), SUM (quantity) AS pizza_sold<br>FROM pizza_sales<br>GROUP BY (pizza_name)<br>ORDER BY 2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*chr_O3s3xk-Vu3bl8zZfFQ.png" /><figcaption>Bottom 3 selling pizzas</figcaption></figure><p>According to our analysis, the Best-selling pizzas are The Classic Deluxe Pizza, The Barbecue Chicken Pizza, and The Hawaiian Pizza. Conversely, the Worst selling pizzas are The Brie Carre Pizza, The Mediterranean Pizza, and The Calabrese Pizza.</p><p><strong>4. What’s our average order value?</strong></p><p>This query computes the average order value by dividing the total revenue (sum of total_price) by the count of unique order IDs. The result is then formatted as a decimal with 10 digits in total, and 2 decimal places.</p><pre>SELECT<br>CAST(SUM(total_price) / COUNT(DISTINCT order_id) AS DECIMAL(10,2)) AS avg_order_value<br>FROM pizza_sales</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/196/1*GO7qNxkA2naUS6O3qfBCDA.png" /><figcaption>Average order value</figcaption></figure><p>The average order value is $38.31</p><p><strong>We require additional KPIs and further analysis to enhance our dashboard.</strong></p><ol><li><strong>Total revenue</strong></li></ol><p>To determine the overall revenue, I utilize the ‘SUM’ function to aggregate the values in the total_price column, followed by applying the ‘ROUND’ function to ensure it’s rounded to the nearest whole number.</p><pre>SELECT<br>ROUND((SUM(total_price)), 0) AS total_revenue<br>FROM pizza_sales</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/173/1*2Ke7IgWps60JEvs6xgjdDg.png" /><figcaption>Total Revenue</figcaption></figure><p>The pizza sales have generated a total revenue of $817,860.</p><p><strong>2. Total pizza sold</strong></p><p>To determine the overall quantity of pizzas sold, I employ the ‘SUM’ function to aggregate the values within the quantity column of the pizza table.</p><pre>SELECT SUM(quantity) AS total_pizzas_sold<br>FROM pizza_sales</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/156/1*T-zfAi4IJA6aUh8d2K5Wzw.png" /></figure><p>A total of 49,574 pizzas were sold throughout the year.</p><p><strong>3. Total orders</strong></p><p>To determine the total number of orders, I utilize the “COUNT” function to count the distinct values in the order_id column from the table.</p><pre>SELECT COUNT(DISTINCT order_id) AS total_orders<br>FROM pizza_sales</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*E6c2gpERhUjWnYHADFX4CA.png" /></figure><p>A total of 21,350 unique orders were recorded.</p><p><strong>4. Percentage of Sales by Pizza Category</strong></p><p>I use the “SUM” function to calculate the total revenue for each pizza category and size by adding up the total_price column values. Then, I use the ‘GROUP BY’ function to group the results by pizza_category. After that, I order the results in descending order based on the percentage of total sales, which is calculated by dividing the sum of total_price for each category and size by the total revenue of the entire pizza_sales table</p><pre>SELECT<br>pizza_category,<br>ROUND((SUM(total_price)), 0) AS total_revenue,<br>ROUND(SUM(total_price) *100 / (SELECT(SUM(total_price)) FROM pizza_sales), 0) AS percentage_of_total_sales<br>FROM<br>pizza_sales<br>GROUP BY pizza_category<br>ORDER BY percentage_of_total_sales DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*CAeBVV5ifBEAol57lAPx_w.png" /></figure><p>The category that generated the highest percentage is Classic with 27% of total sales and then followed by Supreme with 25%</p><p><strong>5. Percentage of Sales by pizza size</strong></p><p>I select the pizza_size column and calculate the total revenue for each pizza size using the “SUM” function on the ‘total_price’ column, rounding it to the nearest whole number. Additionally, I compute the percentage of total sales for each pizza size by dividing the sum of total_price for each size by the total revenue of the entire pizza_sales table. This percentage is casted as a decimal with precision of 10 digits and 2 decimal places. I then group the results by ‘pizza_size’ and order them in descending order based on the percentage of total sales.</p><pre>SELECT<br>pizza_size AS pizza_size,<br>ROUND((SUM(total_price)),0) AS total_revenue,<br>CAST(SUM(total_price) *100 / (SELECT SUM(total_price) FROM pizza_sales) AS DECIMAL(10,2)) AS percentage_of_total_sales<br>FROM<br>pizza_sales<br>GROUP BY<br>pizza_size<br>ORDER BY<br>percentage_of_total_sales DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*gQQ3gdc0LlJ1IMIW2YG4Dg.png" /></figure><p>Based on the analysis, we can infer that the pizza size contributing the highest percentage of sales is Large (45.89%), followed by Medium (30.49%), and Small (21.77%). XLarge and XXLarge sizes contribute 1.72% and 0.12% respectively.</p><p><strong>6. Total pizza sold by pizza category</strong></p><p>I used the “SUM” function to calculate the total quantity of pizzas sold for each pizza category. Then, I grouped the results by pizza category and arranged them in descending order based on the total quantity of pizzas sold.</p><pre>SELECT<br>pizza_category, SUM(quantity) AS total_pizzas_sold<br>FROM<br>pizza_sales<br>GROUP BY<br>pizza_category<br>ORDER BY<br>total_pizzas_sold DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*MLbmsCFoi28YIgDlaGHtZQ.png" /></figure><p>The Classic category recorded the highest number of pizza sales, totaling 14,888. Following closely are the Supreme (11,987) and Veggie (11,649) categories. The category with the lowest sales is Chicken, with a total of 11,050 pizzas sold</p><p><strong>7. Total orders by pizza category</strong></p><p>I’ve utilized the “COUNT” function to determine the distinct number of order IDs for each pizza category. Then, I’ve grouped the results by pizza category and sorted them in descending order based on the total number of orders placed within each category.</p><pre>SELECT pizza_category, COUNT(DISTINCT order_id) AS total_orders<br>FROM pizza_sales<br>GROUP BY pizza_category<br>ORDER BY total_orders DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*9RNwtUU-tB-7LI4bIdXznQ.png" /></figure><p><strong>8. Top 5 and bottom 5 pizzas by revenue, quantity, and orders</strong></p><p>To address this query, I’ll utilize the “SUM” function to compute the quantity, revenue and orders of pizzas sold, along with the “TOP” clause to restrict the results. Additionally, I’ll employ the “GROUP BY” statement to group data by pizza name, and the “ORDER BY” statement with the “DESC” feature to obtain the Top 5 and Bottom 5 results.</p><p><strong>Top 5 pizza by revenue</strong></p><pre>SELECT TOP 5 pizza_name,ROUND((SUM(total_price)), 0) AS total_revenue<br>FROM pizza_sales<br>GROUP BY pizza_name<br>ORDER BY total_revenue DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*N3fVv8UeLhV69JH4yMmCzQ.png" /></figure><p><strong>Bottom 5 pizza by revenue</strong></p><pre>SELECT TOP 5 pizza_name,ROUND((SUM(total_price)), 0) AS total_revenue<br>FROM pizza_sales<br>GROUP BY pizza_name<br>ORDER BY total_revenue;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*unBi8ZbI_c_MY5p7ii8UQQ.png" /></figure><p><strong>Top 5 pizza by quantity</strong></p><pre>SELECT TOP 5 pizza_name, SUM(quantity) AS total_quantity<br>FROM pizza_sales<br>GROUP BY pizza_name<br>ORDER BY total_quantity DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*cFGkl13G6H1hxhlOUik_Vw.png" /></figure><p><strong>Bottom 5 pizza by Quantity</strong></p><pre>SELECT TOP 5 pizza_name, SUM(quantity) AS total_quantity<br>FROM pizza_sales<br>GROUP BY pizza_name<br>ORDER BY total_quantity;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*FPEyX7VK699MXd6NVUuVYg.png" /></figure><p><strong>Top 5 pizza by orders</strong></p><pre>SELECT TOP 5 pizza_name, COUNT(DISTINCT order_id) AS total_orders<br>FROM pizza_sales<br>GROUP BY pizza_name<br>ORDER BY total_orders DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*9hM__If7OpJNMHUigIns4Q.png" /></figure><p><strong>Bottom 5 pizza by orders</strong></p><pre>SELECT TOP 5 pizza_name, COUNT(DISTINCT order_id) AS total_orders<br>FROM pizza_sales<br>GROUP BY pizza_name<br>ORDER BY total_order;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*fgRreX0x3HO14zCRPkhqLg.png" /></figure><h4>Findings and Recommendation</h4><p><strong>Findings</strong></p><ol><li>The dataset comprises a total of 21,350 unique orders, with an average order value of $38, contributing to a total revenue of $817,860.</li><li>The Total quantity of pizza sold as derived from this dataset is 49,574</li><li>The day of the week with the most orders is Friday with 3538 total orders.</li><li>July stands out as the month with the highest number of orders, totaling 1935 and most orders are at the beginning of the year.</li><li>The best-selling pizza is The Classic Deluxe Pizza, with 2,453 orders, while The Brie Carrie Pizza ranks as the worst-selling pizza, with only 490 orders.</li><li>Chicken and Veggie categories are the pizza categories with the worst sales, and XLarge and XXLarge sizes are the least sold pizza sizes.</li></ol><p><strong>Recommendations</strong></p><p>Based on our comprehensive analysis and insights, here are the conclusions drawn and future recommendations aimed at enhancing the success of the pizza company:</p><blockquote>Launch targeted promotions or special deals specifically on Sundays and Mondays to incentivize purchases and boost sales on these slower days.</blockquote><blockquote>Consider promoting more diverse pizza options within the Chicken and Veggie categories to stimulate sales.</blockquote><blockquote>Implement targeted marketing strategies to increase awareness and demand for XLarge and XXLarge pizza sizes.</blockquote><blockquote>Adjust operational hours to align with customer preferences, potentially extending availability during peak demand hours and scaling back during slower periods like early mornings and late nights.</blockquote><blockquote>Conduct further market research to identify emerging trends and preferences, ensuring the menu offerings remain relevant and appealing to customers.</blockquote><blockquote>Analyze customer preferences and behaviors to understand why sales decrease drastically in August to October, exploring potential factors such as seasonal changes, competitor activity, or economic trends.</blockquote><blockquote>Consider implementing loyalty programs or rewards initiatives to encourage repeat purchases and enhance customer retention.</blockquote><blockquote>Leverage data analytics tools to conduct deeper analysis of customer behavior and preferences, identifying opportunities for targeted marketing efforts and personalized promotions.</blockquote><blockquote>Evaluate the feasibility of expanding delivery services or partnering with third-party delivery platforms to reach a wider customer base and increase convenience for consumers.</blockquote><blockquote>Enhance the online ordering experience, ensuring it is user-friendly, efficient, and optimized for mobile devices to capture additional sales from tech-savvy customers.</blockquote><blockquote>Collaborate with local community events or organizations to increase brand visibility and engage with potential customers in the area.</blockquote><h4>Dashboard</h4><p>The Cleaned dataset was uploaded to power BI, addressing initial business queries and introducing additional questions to enhance our report. This time, all insights are vividly represented in visuals. Explore the interactive dashboard <a href="https://app.powerbi.com/view?r=eyJrIjoiODM4ZmU0ZTQtN2U4Yy00YzgwLTg5MDctYjk5NDU2YjBhMjE4IiwidCI6ImQ5YzA4ZjAxLWJkZGQtNGNkOC05MzU2LTBjNmM2NzUyOTAxZiJ9"><strong>here</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*FFeB3mkiY1PJufWxwPzrwg.png" /><figcaption><a href="https://app.powerbi.com/view?r=eyJrIjoiODM4ZmU0ZTQtN2U4Yy00YzgwLTg5MDctYjk5NDU2YjBhMjE4IiwidCI6ImQ5YzA4ZjAxLWJkZGQtNGNkOC05MzU2LTBjNmM2NzUyOTAxZiJ9"><strong>Pizza Sales Dashboard</strong></a><strong>.</strong></figcaption></figure><p>I trust you found value in this post and gained fresh insights. Your thoughts matter, so don’t hesitate to drop a comment for any questions or feedback. Grateful for your time and attention — here’s to continuous learning! 🌟📚</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b75193f50d31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Customer Shopping Behavior Visualization Using Power BI]]></title>
            <link>https://medium.com/@adedeji_s/customer-shopping-behavior-visualization-using-power-bi-50fba2213c90?source=rss-954791611315------2</link>
            <guid isPermaLink="false">https://medium.com/p/50fba2213c90</guid>
            <dc:creator><![CDATA[Sefiat Adedeji]]></dc:creator>
            <pubDate>Sat, 03 Feb 2024 11:23:28 GMT</pubDate>
            <atom:updated>2024-03-12T17:52:03.466Z</atom:updated>
            <content:encoded><![CDATA[<p>In an age dominated by e-commerce and evolving consumer preferences, understanding the intricacies of shopping behavior has become paramount for businesses striving to stay competitive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*hOP1GFQegt86abWK.png" /></figure><p>Every click, every purchase, and every decision made by a customer leaves a trail of data, a goldmine waiting to be deciphered. This data, when wielded effectively, holds the key to unlocking consumer insights and anticipating market trends.</p><p>In this era of abundant information, data visualization emerges as a powerful ally in comprehending complex consumer behaviors. It transforms raw data into a visual narrative, presenting a compelling story that unravels purchasing patterns, preferences, and trends that drive consumer decision-making</p><h3>Objectives</h3><blockquote><em>Examine how location influences purchasing behavior and visualize the variations in buying patterns across different states.</em></blockquote><blockquote><em>Investigate customer preferences in shipping modes, payment methods, and their correlation with shopping frequency or purchase amounts.</em></blockquote><blockquote><em>Visualize purchase amounts, categories, and frequency across different genders to identify potential market segmentation trends.</em></blockquote><blockquote><em>Analyze the influence of age on purchase behavior and preferences</em></blockquote><h3>Step 1: Data Preprocessing and Acquisition</h3><p>Our initial phase involves the extraction and ingestion of the dataset into Power BI. This foundational step enables us to initiate the data cleaning and preparation processes, ensuring the information is refined for effective visualization and analysis.</p><p>The dataset provided (Click <a href="https://drive.google.com/file/d/11NkV3Vx1czftLrICGvusBeZPzqIS88tp/view?usp=drive_link">HERE</a> to view) has 3,900 rows and 18 columns (Customer ID, Age, Gender, Item Purchased, Category, Purchase Amount (USD), Location, Size, Color, Season, Review Rating, Subscription Status, Shipping Type, Discount Applied, Promo Code Used, Previous Purchases, Payment Method, and Frequency of Purchases). Now let’s bring in our data.</p><p>Click on “Get data”, click on Text/CSV to import the CSV file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*x6QTQc9vh-BloohnJVXEiA.png" /></figure><p>To import the data into Power BI, we have the option to either “Load” it directly or choose “Transform Data” for modifications. Opting for ‘Transform Data’ allows us to make necessary adjustments before importing it into Power BI. In my case, since I intend to modify the data, I’ll click on “Transform Data” to ensure a tailored approach to the data import process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*8W8hcDXA8o6csANV1W7Ajg.png" /></figure><p>Now that the data is in the Power Query Editor, I’ve thoroughly examined the dataset. Upon inspection, the columns appear to be in good order. To ensure data integrity, I meticulously reviewed the column quality, checking for any empty cells or errors. Additionally, I verified the data type of each column, and everything seems to be in order. With confidence in the dataset’s quality, I proceeded to click on “Close &amp; Apply” from the tab, bringing the data into Power BI Desktop for further analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1jvELDIoe9ufqHktSbhmRw.png" /></figure><h3>Step 2 : Creating Measures</h3><p>These measures were instrumental in calculating various metrics. To create measures you click on “New measure”</p><ol><li>Total Customer: This indicates the total count of customers in the dataset, providing a clear overview of customer volume for analysis and insights. <strong><em>DISTINCTCOUNT(shopping_behavior[Customer ID])</em></strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*hxaehuN5lO2HIOTilneJXA.png" /></figure><p>2. AvgPurchasedAmt: This metric reveals the average customer expenditure, aiding in understanding spending trends for informed decision-making.<br><strong><em>AVERAGE(shopping_behavior[Purchase Amount (USD)])</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*-4kXPGs0DoNZf8hja99-_A.png" /></figure><p>We followed the same step to create for Max and Min Data Point too.</p><p>3. MaxDataPoint: This measure facilitates the line chart by showcasing the age with the highest average purchase amount, aiding in pinpointing the peak spending age.<br><strong><em>IF(MAXX(ALLSELECTED(shopping_behavior[Age]),shopping_behavior[AvgPurchasedAmt]) = shopping_behavior[AvgPurchasedAmt], MAXX(ALLSELECTED(shopping_behavior[Age]),shopping_behavior[AvgPurchasedAmt]), BLANK())</em></strong></p><p>4. MinDataPoint: This measure enables the line chart by indicating the age with the lowest average purchase amount, assisting in identifying the age group with minimal spending.<br><strong><em>IF(MINX(ALLSELECTED(shopping_behavior[Age]),shopping_behavior[AvgPurchasedAmt]) = shopping_behavior[AvgPurchasedAmt], MINX(ALLSELECTED(shopping_behavior[Age]),shopping_behavior[AvgPurchasedAmt]), BLANK())</em></strong></p><h3>Step 3 : Analysis and Building Visualization</h3><p>visualization is the bridge that connects raw data to meaningful insights. I harnessed power BI’s to create a variety of visuals. This is where our objectives question will be answered.</p><ol><li><strong>Create a highlight table for the distribution of customers by location (state).</strong></li></ol><p>To accomplish this task, we’ll navigate to the Visualization pane and choose the ‘Table’ option. Subsequently, we’ll drag and drop ‘Customer ID’ and ‘Location’ into the columns section, as illustrated below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C3-xwW1wVbWYWIe23O-cjQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/210/1*ZX7hqNTDJt7ly138gJmLKQ.png" /></figure><p>Majority of our customer base is concentrated in Montana and California, whereas Rhode Island and Kansas have comparatively fewer customers.</p><p><strong>2. Create a bar chart to visualize the distribution of purchase amounts by category and season.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CxbhdZvpVyGXR-mL5VpJFg.png" /><figcaption>Distribution of Purchase Amount by Season and Category.</figcaption></figure><p>The Fall season emerged as the peak period for purchases, followed by Spring and Winter, with Summer displaying the least sales activity. In terms of category-wise sales across all seasons, clothing notably dominated, closely trailed by accessories and footwear. Conversely, outerwear consistently depicted the lowest sales performance throughout the seasons.</p><p><strong>3. Create a stacked bar chart that displays the distribution of customers based on the shipping type and the frequency of their purchases.</strong></p><p>From the Visualization pane, we’ll opt for the Stacked Bar Chart. Next, we’ll place the shipping type on the Y-axis, the Purchase amount on the X-axis, and include the frequency of their purchases in the legend for a comprehensive representation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*auW_SIwuMOjm8CMs5q7riQ.png" /><figcaption>Distribution of Customers based on Shipping Type and the Frequency of their Purchase.</figcaption></figure><p>The majority of our customers lean towards Free Shipping as their preferred shipping method, closely followed by Express. Store Pickup, Standard, 2-Day Shipping, and Next Day Air are relatively less favored among our customer base. When it comes to purchasing frequency, Free Shipping and Express options are favored among customers engaging in Annually and Weekly purchases. Conversely, Next Day Air and 2-Day Shipping see more traction among customers who opt for a purchasing of Every 3 months and Monthly.</p><p><strong>4. Build a Line chart showing the relationship between age and average purchase amount. Additionally, label the age with the highest and lowest average purchase amount.</strong></p><p>We’ll opt for the Line Chart in the Visualizations pane, then position Age on the X-axis and Average purchase amount on the Y-axis to visualize the relationship between age and average purchase amount effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VzlQ61hbuCoRpLtMUiKhGA.png" /></figure><p>To identify the age with the highest and lowest average purchase amount, we’ll incorporate our previously created Max Data Point and Min Data Point measures into the Y-axis. This approach enables us to effectively pinpoint the extremes in average purchase amounts across different age groups.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F4iEjvwbASRZfMV4JIJaZQ.png" /><figcaption>Relationship between Age and Average purchase amount.</figcaption></figure><p>Customers aged 53 demonstrated the highest average purchase amount, reaching $68. In contrast, those at age 48 showcased the lowest average purchase amount, totaling $53.</p><p><strong>5. Create a bubble chart/pie chart showing the total purchase amount for each gender.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mvIk6Pn6ystTXt38NRPHyg.png" /><figcaption>Total Purchase Amount by Gender.</figcaption></figure><p>Male customers accounted for the majority of the spending, totaling $158,000, comprising 68% of the total expenditures. Meanwhile, female customers contributed $75,000, constituting 32% of the overall spending.</p><h3>Step 4: Adding Text Boxes</h3><p>To be able to design our dashboard ,text boxes will be integrated. These textual element displays calculated results such as Total number of customers, Average purchased Amount and others.</p><h3>Step 5: Insights and Recommendation</h3><p><strong>Insights</strong></p><ol><li>The dataset comprises 3,900 customers culminating in a total purchase amount of $233,081.</li><li>The majority of our customer base is concentrated in Montana and California, whereas Rhode Island and Kansas have comparatively fewer customers.</li><li>Customers aged 53 demonstrated the highest average purchase amount, reaching $68. In contrast, those at age 48 showcased the lowest average purchase amount, totaling $53.</li><li>Among all seasons, the fall season recorded the highest purchases, predominantly led by the clothing category</li><li>Male customers accounted for 68% of the total expenditures, outspending their female counterparts, who accounted for 32%.</li></ol><p><strong>Recommendation</strong></p><blockquote><strong><em>Regional Focus</em></strong><em>: As our customer base predominantly concentrates in Montana and California, it’s beneficial to channel marketing efforts and promotions towards these regions. However, exploring strategies to boost engagement in Kansas and Rhode Island could expand our market reach.</em></blockquote><blockquote><strong><em>Seasonal and Category Preferences:</em></strong><em> With fall season purchases leading the chart and the clothing category being the most purchased, tailoring seasonal promotions or introducing new lines during fall might amplify revenue. Additionally, optimizing the clothing category with fresh designs or exclusive collections could further boost sales.</em></blockquote><blockquote><strong><em>Shipping Preferences and Purchase Frequency:</em></strong><em> The preference for free shipping and a weekly purchasing trend signifies an opportunity. Offering incentives or loyalty programs around these customer behaviors might further increase engagement and encourage repeat purchases.</em></blockquote><blockquote><strong><em>Age-Based Targeting:</em></strong><em> Create targeted promotions or loyalty programs that resonate with different age groups. Engage customers aged 53 with incentives that appeal to their spending behavior while exploring strategies to encourage increased spending from customers aged 48.</em></blockquote><blockquote><strong><em>Gender-Based Marketing:</em></strong><em> As males make up the majority of our sales, continue to tailor marketing strategies to this demographic while not neglecting the female customer base. Efforts should be made to bridge the gap and potentially expand the female customer segment.</em></blockquote><h3>Creating Dashboard</h3><p>Crafting the dashboard layout was a thoughtful journey in weaving a visual narrative. It involved skillfully arranging diverse visualizations and text boxes to construct a unified and informative dashboard. The intent was to deliver a seamless story through data, ensuring that each element complemented the others, guiding the viewer through a comprehensive understanding of the customer shopping behavior analysis.</p><p>Interact with the Dashboard <a href="https://app.powerbi.com/view?r=eyJrIjoiM2JmMWQxYjUtZjU2Mi00YTI1LWEwNzMtNmI4M2ZiNTI4NTk5IiwidCI6ImQ5YzA4ZjAxLWJkZGQtNGNkOC05MzU2LTBjNmM2NzUyOTAxZiJ9">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*hOnEnSBU9GGxbcjC.png" /><figcaption>Shopping Behavior Dashboard</figcaption></figure><p>I trust you found value in this post and gained fresh insights. Your thoughts matter, so don’t hesitate to drop a comment for any questions or feedback. Grateful for your time and attention — here’s to continuous learning! 🌟📚.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50fba2213c90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Superstore Sales Analysis using SQL]]></title>
            <link>https://medium.com/@adedeji_s/superstore-sales-analysis-using-sql-0d1ee39ad432?source=rss-954791611315------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d1ee39ad432</guid>
            <dc:creator><![CDATA[Sefiat Adedeji]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 18:11:29 GMT</pubDate>
            <atom:updated>2024-03-12T18:11:52.659Z</atom:updated>
            <content:encoded><![CDATA[<p>Optimizing efficiency and profitability by analyzing patterns across our products, regions, categories, and customer segments using SQL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/0*oWkdjMmmBb5WDYqC.jpeg" /></figure><p>In today’s era of rapid technological evolution, establishing robust databases and cultivating specialized departments dedicated to deciphering them isn’t merely an option — it’s a pathway to unparalleled efficiency and success. While execution is vital, the quality of inputs determines the caliber of outputs. As market demands intensify and competition becomes fiercer, staying ahead is imperative.</p><p>The escalating market landscape necessitates an acute understanding of customer needs, trends, and preferences. To thrive in this dynamic environment, leveraging insights becomes paramount. It’s these insights that not only unlock the door to greater efficiency but also lay the foundation for delivering enhanced value to our customers — after all, value is the cornerstone of all success.</p><p>In our exploration of the Superstore’s data through the lens of SQL analysis, we aim to delve deeper. Beyond the sheer numbers lies a treasure trove of information waiting to be unveiled. We’ll navigate through sales records, regional dynamics, customer behaviors, and product trends using SQL as our tool for discovery.</p><h3>Objectives</h3><blockquote><em>Explore customer purchase patterns, segmentations, and preferences through SQL queries, aiming to personalize offerings and improve customer satisfaction.</em></blockquote><blockquote><em>Assess the performance of different regions or markets within the Superstore, identifying areas of strength and opportunities for expansion or optimization.</em></blockquote><blockquote><em>Analyze sales data to identify trends in product performance, seasonal variations, and regional preferences to make informed inventory and marketing decisions.</em></blockquote><blockquote><em>Generate actionable insights from the analysis, empowering decision-makers to make informed and strategic choices that drive the Superstore’s growth and customer satisfaction.</em></blockquote><p><strong>Steps for Superstore Analysis.</strong></p><p><strong>1. Data Collection and Acquisition:</strong> This explaining how we sourced the Superstore sales dataset for analysis, the structure and the key attributes of our dataset.</p><p><strong>2. Data Cleaning and Preprocessing:</strong> This involves steps taken to clean and preprocess the dataset to ensure its quality and reliability. The techniques used for handling missing values, standardizing formats, and cleaning inconsistent data.</p><p><strong>3. Exploratory Data Analysis (EDA) with SQL:</strong> Introduce the exploratory phase and its significance in understanding the dataset’s characteristics. showing the SQL queries employed for uncovering sales trends, regional variations, customer behaviors, and product insights.</p><p><strong>4. Advanced SQL Techniques:</strong> Highlight the utilization of more complex SQL techniques for deeper analysis, where the advanced SQL functions, window functions, will be used to derive insights beyond standard queries.</p><p><strong>5. Insights and Recommendations:</strong> Summarize the key insights derived from the analysis. Discuss actionable recommendations based on SQL-driven insights for enhancing operations, optimizing sales, or improving customer experiences.</p><p><strong>6. Dashboard and Report</strong>: A visualization that explain each segments and add key performance Indicators.</p><h3>1. Data Collection and Acquisition</h3><p><strong>1.1 Data Source and Structure</strong></p><p>In this analysis, we’ll employ two dataset sourced from Kaggle, order dataset and return dataset. (Click <a href="https://drive.google.com/drive/folders/1e7B_JO2fdBPyAFuKLKqJd-MLrnr1-sOv?usp=drive_link">HERE</a> for the dataset).The order dataset encompassing data with 9995 rows, including the header. It contains data recorded between the 3rd of January 2014 (the first order date) to the 30th of December 2017. While the return dataset encompassing data with 297 rows</p><p>The order data contains the 21 columns namely; Row ID, Order ID, Order Date, Ship Date, Ship Mode, Customer ID , Customer Name, Segment, Postal Code, City, State, Country, Region, Product ID, Category, Sub-Category, Product Name, Sales, Quantity, Discount and Profit. and the return data contains just 2 columns namely: Returned, Order ID</p><p><strong>1.2 Tools</strong></p><p>We’ll utilize PostgreSQL as our primary data tool for the process of data cleaning, analysis and PowerBI for visualization.</p><h3>2. Data Cleaning and Preprocessing</h3><p>2. 1 Creating a database, setting up tables, and importing data.</p><p>Let’s navigate to our PostgreSQL, where we’ll create a database. Simply right-click and name it as “Superstore”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*dSGBKsx6fX9gyc8wsoH4Sg.png" /></figure><p>To create tables, open the Superstore database, double-click to access tables, then right-click to initiate table creation. Under “General,” input your desired table name. Proceed to define columns by specifying names and corresponding data types, and save it once done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*u6nSEnktCPudwhR19JvK4w.png" /></figure><p>For data importation: Right-click on the newly created order table, then select Import. Locate our file by searching for its filename, choose the option for headers, designate “,” as our delimiter, and click OK to finalize the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*K23IhN-47LEDHRXAHiJOzg.png" /></figure><p>We observed that the import of our orders table failed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kMqOcmi8bamce5cdVHJKg.png" /></figure><p><strong>2.2 Checking values in column for accuracy and consistency.</strong></p><p>We encountered issues importing our dataset, specifically within the product name column of the order table. To rectify this, we utilized Excel’s ‘find and replace’ function. The task involved substituting instances of ‘,’ with an empty space ‘ ‘ to ensure data accuracy and facilitate a seamless importation process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7VwCV-ZV5VYFUhbA.png" /></figure><p>Following these modifications, successful importation of the dataset was achieved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*d_5V0qSkrK_0K_CL.png" /></figure><p>2.3 Observe our dataset.</p><p>Check the first 5 rows to make sure it imported well.</p><pre>SELECT *<br>FROM orders<br>LIMIT 5;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*xsSCFIzxfF0NYQ_a.png" /></figure><p>2.4 Checking for missing values.</p><pre>SELECT *<br>FROM orders<br>WHERE rowid IS NULL OR orderid IS NULL OR orderdate IS NULL OR shipdate IS NULL OR sales IS NULL;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*3XhAmn9VxE1nVWDN.png" /></figure><p>It revealed blank this shows that we have no missing values.</p><p>2.5 Checking for duplicate Row.</p><pre>SELECT *<br>FROM orders<br>WHERE (rowid orderid, orderdate, shipdate, shipmode, customerid, customername, segment, country, city, postalcode, region, productid, category, &quot;sub-category&quot;, productname, sales, quantity, discount, profit)<br>IN (<br>    SELECT rowid, orderid, orderdate, shipdate, shipmode, customerid, customername, segment, country, city, postalcode, region, productid, category, &quot;sub-category&quot;, productname, sales, quantity, discount, profit<br>    FROM orders<br>    GROUP BY rowid, orderid, orderdate, shipdate, shipmode, customerid, customername, segment, country, city, postalcode, region, productid, category, &quot;sub-category&quot;, productname, sales, quantity, discount, profit<br>    HAVING COUNT(*) &gt; 1<br>)<br>ORDER BY rowid, orderid;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PT6s4N7xPutiWMWs.png" /></figure><p>The query returns an empty table, showing there are no duplicate rows.</p><h3>3. Exploratory Data Analysis (EDA)</h3><p>1. What is the total sales revenue for all orders in the dataset?</p><pre>SELECT ROUND(SUM(sales)) AS Total_sales_revenue <br>FROM orders</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/188/0*TKIlj8weJlIBq2rh.png" /></figure><p>The total revenue for all orders is $2,297,201</p><p>2. What is the total profit for all orders in the dataset?</p><pre>SELECT ROUND(SUM(profit)) AS TotalProfit<br>FROM orders;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/155/0*Fgs3aOMDkbSN6R0T.png" /></figure><p>The Total profit generated from all orders amounts to $286,397</p><p>3. How many orders are in the dataset?</p><pre>SELECT COUNT(Orderid) AS Total_Orders<br>FROM orders;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/108/0*IILAqsay_RFRhsNm.png" /></figure><p>There are 9994 orders in this dataset.</p><p>4. What is the average discount applied to orders?</p><pre>SELECT ROUND(AVG(discount),2) AS AverageDiscount<br>FROM orders;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/0*QDAidAj6sYHEUHNO.png" /></figure><p>The average discount applied across all orders is $0.16.</p><p>5. Which product category has the most orders?</p><pre>SELECT category, COUNT(*) AS NumberOfOrders<br>FROM orders<br>GROUP BY Category<br>ORDER BY NumberOfOrders DESC<br>LIMIT 1;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/0*jMPawx2Q8wPVQwgr.png" /></figure><p>The Office Supplies category had the most order.</p><p>6. What is the most profitable product?</p><pre>SELECT productname, ROUND(SUM(profit)) AS TotalProfit<br>FROM orders<br>GROUP BY 1<br>ORDER BY 2 DESC<br>LIMIT 1;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/0*V_L0qHS_bo-FqqfD.png" /></figure><p>The product yielding the highest profit is the Cannon Image Class 2200 Advanced Copier, generating a total profit of $25,200.</p><p>7. How many orders were returned, and what percentage of all orders does this represent?</p><pre>SELECT ReturnedOrdersCount,TotalOrdersCount,<br>ROUND((ReturnedOrdersCount * 100.0) / TotalOrdersCount) AS PercentageReturnedOrders<br>FROM<br>    (SELECT COUNT(*) AS ReturnedOrdersCount FROM returns) AS ReturnedOrders,<br>    (SELECT COUNT(*) AS TotalOrdersCount FROM orders) AS TotalOrders;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/0*DN_wzVx070mbqwvB.png" /></figure><p>296 orders got returned, which represent 3 % of all orders</p><p>8. Who are the top 5 customers based on their total spending?</p><pre>SELECT customername, SUM(sales) AS TotalSpending<br>FROM orders<br>GROUP BY customername<br>ORDER BY TotalSpending DESC<br>LIMIT 5;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/0*6X7yQB_ftFV7LFEl.png" /></figure><p>The Top five Customers based on their total spending are Sean Miller, Tamara Chand, Raymond Buch, Tom Ashbrook, Adrian Barton</p><p>9. What is the total sales revenue for each region?</p><pre>SELECT region, ROUND(SUM(sales)) AS TotalSalesRevenue<br>FROM orders<br>GROUP BY region<br>ORDER BY TotalSalesRevenue DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/0*YdJWNYNr6PLQKpKe.png" /></figure><blockquote><strong><em>West:</em></strong><em> The sales revenue generated from the West region amounts to $725,458.</em></blockquote><blockquote><strong><em>East:</em></strong><em> The East region contributed $678,781 in sales revenue.</em></blockquote><blockquote><strong><em>Central: </em></strong><em>Sales revenue from the Central region reached $501,240.</em></blockquote><blockquote><strong><em>South:</em></strong><em> The South region recorded sales revenue totaling $391,722.</em></blockquote><p>10. How many orders were placed in each year?</p><pre>SELECT EXTRACT(YEAR FROM orderdate) AS year, COUNT(*) AS NumberofOrders<br>FROM orders<br>GROUP BY year<br>ORDER BY year;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/186/0*wR3Ob7snY53Fwyxn.png" /></figure><p>This data illustrates the total number of orders placed in each year over a specified period:</p><blockquote><em>2014: There were 1,993 orders placed during this year.</em></blockquote><blockquote><em>2015: The number of orders increased to 2,102.</em></blockquote><blockquote><em>2016: The order count further grew to 2,587.</em></blockquote><blockquote><em>2017: The highest number of orders, reaching 3,312, was recorded in this year.</em></blockquote><p>11. What is the average discount for each product category?</p><pre>SELECT category,ROUND(AVG(discount), 2) AS AverageDiscount<br>FROM orders<br>GROUP BY category;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/0*madhpiN7pZwaEk8R.png" /></figure><p>On average, Furniture items exhibit the highest discount rate, averaging at $0.17 per item. Office supplies follow closely, offering discounts averaging $0.16 per item. Conversely, technology products showcase the lowest average discount rate, standing at $0.13 per item</p><p>12. How many returned orders are there for each product category?</p><pre>SELECT o.category, COUNT(r.orderid) AS ReturnedOrdersCount<br>FROM orders o<br>JOIN returns r ON o.orderid = r.orderid<br>GROUP BY o.category;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/0*pvkuHkMjqajUHwyk.png" /></figure><p>The Furniture category has a recorded count of 171 returned orders, while office supplies exhibit 473 returned orders, and Technology items show 156 returns.</p><p>13. Which customers have returned orders, and how many times?</p><pre>SELECT o.customername, COUNT(r.orderid) AS ReturnCount<br>FROM orders o<br>LEFT JOIN returns r ON o.orderid = r.orderid<br>GROUP BY o.customername<br>HAVING COUNT(r.orderid) &gt; 0<br>ORDER BY 2 DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/0*JHw7St0b007G8CZ3.png" /></figure><h3>4. Advanced SQL Techniques</h3><p>1. Monthly Sales Trend: Create a view that shows the monthly sales trend for each year. Include the year, month, and total sales for each month.</p><pre>CREATE VIEW Monthly_sales_trend AS<br> SELECT EXTRACT(YEAR FROM orderdate) AS year,  EXTRACT(MONTH FROM orderdate) AS months, <br> SUM(sales) AS Totalsales<br> FROM orders<br> GROUP BY year, months<br> ORDER BY year, months</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/0*6FEyvNDaslTzZ5DH.png" /></figure><pre>--QUERYING THE VIEW--<br>SELECT *<br>FROM Monthly_sales_trend</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/0*WdLAT6Fpz1iNwObn.png" /></figure><p>2. Identify customers who have made at least five purchases and calculate their average order value.</p><pre>SELECT customername, COUNT(*) AS TotalOrders, ROUND(AVG(sales), 2) AS AverageOrderValue<br>FROM orders<br>GROUP BY CustomerName<br>HAVING COUNT(*) &gt;= 5<br>ORDER BY TotalOrders, AverageOrderValue DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/0*rIPnlI0niqEpqizD.png" /></figure><p>3. Product Category Ranking: Rank product categories by total sales in descending order using window functions.</p><pre>SELECT category, Round(SUM(sales)) AS TotalSales,<br> RANK() OVER (ORDER BY SUM(sales) DESC) AS CategoryRank<br>FROM orders<br>GROUP BY category<br>ORDER BY TotalSales DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/0*zh7m3x7YQ-M_HqaY.png" /></figure><p>4. Find the top 5 customers who have made the highest total sales in each state, along with the product category they mostly purchased. Use a Common Table Expression (CTE) to calculate the total sales for each customer in each state, and then retrieve the top 5 customers for each state. Additionally, provide the product category that these top customers predominantly bought in each state.</p><pre>WITH CustomerSales AS (<br>    SELECT <br>        customername,<br>        state,<br>        category,<br>        SUM(sales) AS Total_Sales,<br>        RANK() OVER (PARTITION BY state ORDER BY SUM(sales) DESC) AS Sales_Rank<br>    FROM orders<br>    GROUP BY customername, state, category<br>)<br>SELECT <br>    customername,<br>    state,<br>    category AS Predominant_Product_Category,<br>    Total_Sales,<br>    Sales_Rank<br>FROM CustomerSales<br>WHERE Sales_Rank &lt;= 5<br>ORDER BY state, Total_Sales DESC;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/0*CI9kwusrIu3hr265.png" /></figure><p>5. Yearly Growth Rate: Calculate the yearly growth rate in sales from one year to the next, using window functions.</p><pre>WITH YearlySales AS<br>(<br> SELECT EXTRACT(YEAR FROM orderdate) AS Year, ROUND(SUM(Sales))AS PresentYrSales,<br> LAG(ROUND(SUM(SALES))) OVER(ORDER BY EXTRACT(YEAR FROM orderdate)) AS PreviousYrSales<br> FROM orders<br> GROUP BY year<br>)<br>SELECT Year,PresentYrSales, PreviousYrSales, ROUND(((PresentYrSales - PreviousYrSales)/PreviousYrSales)*100,2)<br>FROM YearlySales;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/0*dKPHTOxvLGD5bOXh.png" /></figure><p>6. Category Sales Growth: Calculate the year-over-year growth in sales for each product category.</p><pre>WITH YearbyCategorySales AS<br>(<br> SELECT EXTRACT(YEAR FROM orderdate) AS Year, Category, ROUND(SUM(sales)) AS PresentYrSales<br> FROM orders<br> GROUP BY Year, category<br> ORDER BY Year<br>)<br><br>SELECT C1.category, C1.Year, C2.Year, C1.PresentYrSales AS PrevYrSales, C2.PresentYrSales AS PresentYrSales,<br>ROUND((C2.PresentYrSales - C1.PresentYrSales)/C1.PresentYrSales * 100,2) AS PercetageGrowth<br>FROM YearbyCategorySales C1<br>JOIN YearbyCategorySales C2<br>ON C1.Year = C2.Year-1 AND C1.category = C2.category;</pre><p>The Furniture category demonstrated consistent growth year over year, indicating a positive trend in sales. Conversely, there was a decline observed in the sales of both office supplies and technology products across the same period.</p><h3>5. Insights and Recommendation</h3><p><strong>5.1 Insights</strong></p><ol><li>The dataset comprises 9,994 orders, culminating in a total revenue of $2,297,201.</li><li>The most performing regions are the West then the East, Central and South regions in that order.</li><li>Cannon Image Class 2200 Advanced Copier is the most profitable product</li><li>The order count exhibited a consistent increase year by year, escalating from 1,993 orders in 2014 to a peak of 3,312 orders in 2017. Among the observed years, 2017 marked the highest number of orders, while 2014 recorded the lowest volume.</li><li>Among categories, “Office Supplies” stands out with 6,026 orders, concurrently having the highest count of returns at 296.</li><li>The products in the “Technology” category generated the highest sales.</li></ol><p><strong>5.2 Recommendation</strong></p><p>Based on our comprehensive analysis and insights, here are the conclusions drawn and future recommendations aimed at enhancing the success of our Superstore:</p><blockquote><em>Regional Focus: Leverage the success of the West and East regions by further optimizing strategies in these areas. Consider initiatives to bolster performance in the Central and South regions, possibly by evaluating market trends or tailoring offerings to regional preferences.</em></blockquote><blockquote><em>Product Optimization: Given the success of the “Cannon Image Class 2200 Advanced Copier,” explore opportunities to promote and expand offerings within this high-profit product category. Additionally, emphasize products from the “Technology” category to sustain and potentially boost sales.</em></blockquote><blockquote><em>Order Management and Returns: Analyze the reasons behind the high volume of orders and returns in the “Office Supplies” category. Implement measures to streamline orders and address the return rate, aiming to enhance customer satisfaction and reduce returns.</em></blockquote><blockquote><em>Yearly Order Growth: Capitalize on the upward trend in yearly order counts by forecasting future demands and adequately preparing inventory and resources to meet increased orders, especially during peak 2017.</em></blockquote><h3>6. Dashboard and Report</h3><p>The Cleaned dataset was uploaded to power BI, addressing initial business queries and introducing additional questions to enhance our report. This time, all insights are vividly represented in visuals. Explore the interactive report <a href="https://app.powerbi.com/view?r=eyJrIjoiM2JhYTU3NTAtNDcyOS00ZDM4LThkZTUtYmE1ODkzMjQxZDZkIiwidCI6ImQ5YzA4ZjAxLWJkZGQtNGNkOC05MzU2LTBjNmM2NzUyOTAxZiJ9"><strong>here</strong></a>, and feel free to pose more questions to unravel further layers of the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*v7ixdvf3IIcDo9up0_NRVg.png" /><figcaption><a href="https://app.powerbi.com/view?r=eyJrIjoiM2JhYTU3NTAtNDcyOS00ZDM4LThkZTUtYmE1ODkzMjQxZDZkIiwidCI6ImQ5YzA4ZjAxLWJkZGQtNGNkOC05MzU2LTBjNmM2NzUyOTAxZiJ9">Super Store Dashboard</a></figcaption></figure><p>I trust you found value in this post and gained fresh insights. Your thoughts matter, so don’t hesitate to drop a comment for any questions or feedback. Grateful for your time and attention — here’s to continuous learning! 🌟📚</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d1ee39ad432" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RFM Analysis for Customer Segmentation and Profiling using Excel]]></title>
            <link>https://medium.com/@adedeji_s/rfm-analysis-for-customer-segmentation-and-profiling-using-excel-175afdb2663d?source=rss-954791611315------2</link>
            <guid isPermaLink="false">https://medium.com/p/175afdb2663d</guid>
            <dc:creator><![CDATA[Sefiat Adedeji]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 09:54:06 GMT</pubDate>
            <atom:updated>2024-01-28T19:06:28.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HSJltwYeLcfE_33maGoG1w.png" /></figure><h3><strong>Introduction</strong></h3><p>In today’s data-driven landscape, understanding customer behavior is key to navigating the competitive market. Among the myriad methods available, RFM Analysis stands tall as a powerful tool, offering invaluable insights into customer engagement and purchasing patterns.</p><p>RFM, short for Recency, Frequency, Monetary, delves deep into the core of customer interactions. This analytical technique segments customers based on three fundamental dimensions</p><ol><li><em>Recency (R): This refers to the measure of how recently a customer has engaged with a business, made a purchase, or interacted with a product or service.</em></li><li><em>Frequency (F): This denotes the rate or number of times a customer engages with the business within a specified period. A higher frequency signifies a more engaged and loyal customer base.</em></li><li><em>Monetary (M): This reflects the total value or monetary contribution of a customer to the business within a given period. Monetary also emphasizes the value each customer brings to the business.</em></li></ol><p>By leveraging these dimensions, RFM Analysis enables businesses to categorize customers into distinct segments, unveiling hidden trends and preferences that might otherwise remain obscured.</p><h3><strong>Objectives</strong></h3><blockquote>To understand the distribution and size of customers across segments, highlighting the prevalence of each group.</blockquote><blockquote>Comparing RFM values among segments to discern differences in engagement, purchase behavior, and spending patterns.</blockquote><blockquote>To analyze demographic factors within segments to identify preferences or correlations between customer profiles and behavior.</blockquote><blockquote>To Examine how educational backgrounds and marital status influence customer behavior within different segments, revealing potential trends or associations.</blockquote><h3><strong>Methodology</strong></h3><h4><strong>Data Source</strong></h4><p>In this analysis, we’ll employ a dataset sourced from Kaggle, encompassing data on 2,240 customers and their purchasing behavior at a grocery store. The dataset comprises 27 columns, each containing valuable insights about each customers. You can download the dataset <a href="https://github.com/SefiatAdedeji/RFM_Analysis_using_Excel/blob/main/marketing_campaign.csv">here</a>.</p><h4><strong>Tool</strong></h4><p>We’ll utilize Microsoft Excel as our primary data tool for the process of data cleaning, analysis, and visualization.</p><h4>Data Dictionary</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*srWBh-strFFSuNxWLPF9iw.png" /></figure><p>Step-by-step for RFM Analysis</p><p>1. <strong>Data Cleaning:</strong> This involves imputing missing values, rectifying inaccuracies in spellings, and eliminating duplicate entries from the7 dataset</p><p>2. <strong>Data Transformation</strong>: Creating new columns based on existing columns, Calculate the customer’s age based on their year of birth; create a new column for the total number of children; Calculate the total monetary value spent by each customer; and the frequency (number of purchases)for each customer.</p><p>3. <strong>Feature Selection</strong>: Selecting the precise data fields from the dataset that hold relevance and significance for the analysis at hand.</p><p>4. <strong>Percentrank: </strong>Create a new column for Percentrank for Monetary Value, Frequency, and Recency to normalize these metrics.</p><p>5. <strong>Create RFM Score: </strong>Calculate an RFM score based on the Percentrank values, summing the three columns created in the previous step, and create a new column for Percentrank.inc for the RFM score to segment customers based on their combined RFM values.</p><p>6. <strong>Customer Segmentation: </strong>Create a new column called “Customer Segment” and segment customers based on the RFM score using VLOOKUP.</p><p>7.<strong> Pivot Table: </strong>Create a pivot chart displaying the count of customers in each segment (Top customers, Loyal customers, At-risk, and immediate attention). create a customer profile table that shows all four customer segment and the percentage of customer segment, average age, average income, average number of children, most common Education and Marital status</p><p>8. <strong>Visualization:</strong> Create visualizations that explain each segment and add key performance indicators (KPIs). Include demographic values (average age, income, number of children, marital status) for the top customers and the “Immediate Attention” segment to understand customer profiles better.</p><h3>1. Data Cleaning</h3><p>1.1 Separating data into tabs.</p><p>We employed the “Text-to-Columns” function to divide the CSV-formatted data into distinct tabs or columns, streamlining the organization and accessibility of the dataset for further analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*o_TisLZeaYaWPiqhGk1uYA.png" /></figure><p>1.2 Checking for missing values.</p><p>Utilizing the COUNTBLANK() function, we scanned our dataset for any missing values. The analysis revealed 24 missing data points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NYJaIqgZYGsiY8lRd50JnA.png" /></figure><p>Subsequent column-wise filtering identified these gaps exclusively in the ‘income’ column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*o6LwbyYE7tJgjyx5ymPVcA.png" /></figure><p>While our dataset consists of over 2000 rows, prioritizing data integrity, we opted to heighten data quality by excluding the 24 rows with missing values from further analysis.</p><p>1.3 Checking for duplicate rows.</p><p>To identify and eliminate duplicate rows within the dataset. This process ensures the accuracy and reliability of our data, mitigating redundancy and potential errors in subsequent analyses.</p><p>The ‘Remove Duplicate’ was used and this can be found within the Data tab section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*5wHFnsKzq4i79GlEZhArhw.png" /></figure><p>No values were duplicated.</p><p>1.4 Education Level Column</p><p>In the Education Column we have 5 Levels which are: 2n Cycle, Basic, Graduation, Masters, PhD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*eOJr2eqeyXwpyvgevwcDew.png" /></figure><p>so we need to condensed these levels into three broader categories which are: Undergraduate, Graduate and Post-graduate by using the “Find and Replace feature”.</p><p><em>a. Basics and 2n cycle — Undergraduate</em></p><p><em>b. Graduation — Graduate</em></p><p><em>c. Masters and PhD — Post-graduate</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*2-Yy5lNm7ROC-bPTQHHIVg.png" /></figure><p>1.5 Marital Status Column</p><p>The Marital Status are of 8 different stages: Absurd, Alone, Divorced, Married, Single, Together, Widowed, and YOLO, we need to condensed these levels to just two</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*6bNtZizhAEkwUaGOopB_AQ.png" /></figure><p><em>a. Absurd, Alone, Divorced, Single, Widow, and YOLO — Single</em></p><p><em>b. Married and Together — Married</em></p><p>To achieve this we need to use the “Find and Replace” feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*0ytp4RHCP407hKDCNSJIuw.png" /></figure><h3>2. Data Transformation</h3><p>2.1 Create a Age column</p><p>This action aims to calculate the age of individuals based on their birth year data, providing a convenient reference for age-related analysis and segmentation within the dataset. To create a new column labeled “Age,” one approach involves employing the formula “=YEAR(TODAY()) — B2” or subtracting the values in the “Year_birth” column from the current year (2023).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*MUjgLn65HwWTk_XXrCez4w.png" /></figure><p>We detected three Outliers in our Age column (123,124, 130). We proceed to remove them from the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*2dC-s0QMwj4y7VFp-v7pjg.png" /></figure><p>2.2. Create a new column for the Number of children.</p><p>To derive a new column labeled “Number_of_children,” we will sum the values present in the “Kidhome” and “Teenhome” columns using the formula “=SUM(G2,H2)”. This calculation intends to consolidate the count of children across both columns, providing a comprehensive metric for child-related considerations within the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*5A2ODbmwrGMW0-zaGXPrOA.png" /></figure><p>2.3 Create a column for monetary value</p><p>This is derived by Summing all the Mnt columns, Each of these columns represents expenditures on specific items within the shop. =SUM(L2:Q2)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*TFJyYPt--tdlSr0kjQ1rVw.png" /></figure><p>2.4 Create a column for Frequency</p><p>To determine our Frequency which evaluates how frequently a customer makes purchases. We will sum up data from the columns NumWebPurchases, NumCatalogPurchases and NumStorePurchases to calculate the Frequency =SUM(T10:V10)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*y_bya5KIDwZi4fYbVe8R3g.png" /></figure><h3>3. Feature Selection</h3><p>We’re pinpointing the columns crucial for our RFM analysis, strategically eliminating non-essential ones. The finalized selection of columns vital for the RFM analysis comprises Age, Education, Marital Status, Income, and Number of Children, complemented by the Recency, Frequency, and Monetary Value columns. This streamlined dataset focuses on key metrics essential for our targeted customer segmentation and profiling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*8VWWLlXVIYshKIFFVGkYSQ.png" /></figure><h3><strong>4. Percentrank</strong></h3><p>Our aim is to generate three additional columns that calculate the percentile rank for Recency, Frequency, and Monetary Value. To accomplish this task, we’ll utilize the Percentrank.inc function. We opted for this function due to its inclusive nature, considering the value itself in the ranking process. To acquire whole numbers spanning from 0 to 10, we’ll subsequently multiply the obtained result by 10.</p><p>For frequency and monetary value scores, the below formula was used respectively.</p><p>=PERCENTRANK.INC($G:$G,G2,1)*10</p><p>=PERCENTRANK.INC($H:$H,H2,1)*10</p><p>Our ranking formula assigns a score of 0 to the lowest and 10 to the highest values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*0sU87kdUd1rmsIRlOczctg.png" /></figure><p>In calculating the Recency score, we’ve adjusted the formula to incorporate the temporal aspect within a year. our objective is to grant a lower score to the former and a higher score to the latter, emphasizing that a recent purchase should yield a higher score compared to a longer time gap since the last transaction.</p><p>To address this, we will implement the following formula for the recency rank column:</p><p>= (1 — PERCENTRANK.INC($F:$F, F2, 1)) * 10</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*5lAzZWEvChraEktaEYi7JQ.png" /></figure><h3><strong>5. Create RFM Score</strong></h3><p>To compute our RFM Score, a column for RFM needs to be created. This score for each customer will be derived by summing the individual scores corresponding to Recency, Frequency, and Monetary Value. This allows us to synthesize a comprehensive RFM Score, consolidating the three key metrics into a singular evaluative measure for each customer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*5Sh7iokc0O12BPuXX75tfA.png" /></figure><p>RFM score column will be calculated using the PERCENTRANK formula and incorporated it into the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*W1pJvz3pVJSj7ZSALVy79A.png" /></figure><h3>6. Customer Segmentation</h3><p>We will create a table showing customer segment and RFM score. The criteria are delineated in the table provided below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*weE73MQwlBcXjZatmgBOJg.png" /></figure><p>=VLOOKUP(M2,$S$16:$T$17,2,FALSE)</p><p>This VLOOKUP formula will be used to assign distinct customer segment categories to the RFM scores obtained.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*7HnEu3zJk1_e9LHRfGLTsg.png" /></figure><h3>7. PIVOT TABLE.</h3><p>These tables serve as powerful tools, enabling the extraction of nuanced insights into the distinct traits, behaviors, and preferences exhibited within each segmented group.</p><p><strong>7.1 Pivot table for the total number of customers and percentage of customer in each segment</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*BG5laEVwAmn_w6c2vu6-Ng.png" /></figure><p><strong>7.2 Pivot Table showing the average Recency, Frequency, and Monetary value for each customer segment</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*xlSSmBgQ16j-XeYcktjcgQ.png" /></figure><p><strong>7.3 Pivot Table showing the average age, income, and number of children by customer segment</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*tZuCkjyoplxKLAHKpGA71Q.png" /></figure><p><strong>7.4 Pivot Table showing the Customer Count by Education Group within each Segment.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*v_VCkb-ucG7F0RNay0s7Gw.png" /></figure><p>The Graduate is the most prevalent across the four customers.</p><p><strong>7.5 Pivot Table showing the Customer Count by Marital Status Group within each Segment.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*W8ZicxU6SOCOkbw96NyRXg.png" /></figure><p><strong>7.6</strong> <strong>create a customer profile table that shows all four customer segment and the percentage of customer segment, average age, average income, average number of children, most common Education and Marital status.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ZgRAF-7mhM7Uqv6fb2eNrw.png" /></figure><h3><strong>Insights</strong></h3><ol><li>Upon analyzing our dataset, a significant observation emerged regarding customer demographics: the majority, comprising 1429 individuals, are married, while 784 customers identify as singles. Moreover, a noteworthy trend in education groups was revealed, with a substantial portion of our customer base categorized as Graduates.</li><li><strong>At Risk/Need Attention</strong></li></ol><p>This Customers account for 33% of our customer segment. On average, this segment has made 9 purchases, spending approximately $285 per purchase. With an average age of 54, their income stands at $44,105. Identifying this segment allows us to focus on targeted strategies to re-engage and retain these customers, considering their purchasing behavior and demographic profile.</p><p><strong>3. Immediate Attention</strong></p><p>Customers needing Immediate Attention represent 21% of our total customer base. This segment demonstrates a noteworthy spending pattern, with an average purchase value of $55. However, they exhibit the lowest scores in frequency, monetary value, and recency metrics. On further examination, this segment, with an average age of 51, presents the lowest average income at $32,364 among similar segments.</p><p>4. Loyal Customer</p><p>This accounts for 26% of our customer segments, the Loyal Customers segment emerges as a robust cohort, showcasing notable engagement metrics. This segment demonstrates a commendable frequency of 17 purchases, following closely behind our Top Customers. Additionally, their substantial spending per purchase, averaging $960, signifies a consistent investment in our products or services.</p><p>5. Top Customer</p><p>The Top Customers Segment showcases compelling attributes within our dataset. On average, these customers made 21 purchases, illustrating a robust level of engagement. Notably, their average spending per purchase stands impressively high at $1303, indicating their propensity for high-value transactions.</p><p>Moreover, this segment boasts an exceptional average income of $72,790, the highest among the customer segments analyzed. This noteworthy financial capacity highlights their potential for substantial purchasing power and long-term value to our business.</p><h3><strong>Recommendations</strong></h3><h4><strong>At Risk/Need Attention</strong></h4><ol><li><em>Customer Experience Enhancement: Focus on enhancing customer experience through improved service, seamless transactions, or dedicated customer support. Positive experiences can reignite their engagement and loyalty.</em></li><li><em>Loyalty Programs: Introduce loyalty programs with incentives tied to repeat purchases. Offer rewards, points, or tier-based benefits to incentivize continued engagement.</em></li><li><em>Feedback and Surveys: Seek their feedback through surveys or direct communication. Understanding their concerns or preferences can guide tailored improvements and offerings.</em></li></ol><h4><strong>Immediate Attention</strong></h4><p><em>1. Value-Oriented Offers: Develop cost-effective offerings or bundled deals that provide value without demanding substantial spending, aligning with their lower average purchase value.</em></p><p><em>2. Sensitivity to Price Sensitivity: Consider pricing strategies that accommodate their income level, ensuring products or services remain accessible without compromising quality.</em></p><h4>Loyal Customer</h4><ol><li><em>Referral Incentives: Encourage these loyal customers to refer others through referral programs, offering incentives or benefits for successful referrals.</em></li><li><em>Engagement-based Rewards: Offer rewards tied to continued engagement, such as milestone-based incentives or anniversary offers to celebrate their loyalty tenure.</em></li></ol><h4>Top Customer</h4><p><em>1. Personalized Recommendations: Use data-driven insights to offer personalized recommendations or bespoke offerings, showcasing an understanding of their preferences.</em></p><p><em>2. Specialized Customer Service: Provide a dedicated account manager or concierge service, ensuring their unique needs and preferences are catered to promptly.</em></p><p><em>3. VIP Treatment and Exclusive Services: Offer personalized VIP treatment, exclusive services, or dedicated customer support to acknowledge and appreciate their high-value patronage.</em></p><h3><strong>Dashboard</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmnXugPZHtihYotEVmW0uw.png" /></figure><p>Thanks for reading.</p><p>Link to the <a href="https://github.com/SefiatAdedeji/RFM_Analysis_using_Excel/blob/main/RFM_Customer_Segmentation%20Analysis.xlsx">Excel file</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=175afdb2663d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>