<?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 Ming S. Lu on Medium]]></title>
        <description><![CDATA[Stories by Ming S. Lu on Medium]]></description>
        <link>https://medium.com/@ming.s.lu1617?source=rss-4822646f41ce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*jZVw8P0_FHgzSJqY</url>
            <title>Stories by Ming S. Lu on Medium</title>
            <link>https://medium.com/@ming.s.lu1617?source=rss-4822646f41ce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 20:31:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ming.s.lu1617/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[I collected 37 websites of the top 10 Excel formulas]]></title>
            <link>https://medium.com/@ming.s.lu1617/i-collected-36-websites-of-the-top-10-excel-formulas-58b3baeea219?source=rss-4822646f41ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/58b3baeea219</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[excel]]></category>
            <dc:creator><![CDATA[Ming S. Lu]]></dc:creator>
            <pubDate>Sun, 10 Mar 2024 05:16:27 GMT</pubDate>
            <atom:updated>2024-03-12T11:06:31.704Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Analysis Excel Project</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*nTu1GKBDA2ZNk8MASDE1XA.png" /><figcaption>Photo credit: excelhumor.xlsx <a href="https://www.instagram.com/p/CgNFA2tu357/">https://www.instagram.com/p/CgNFA2tu357/</a></figcaption></figure><h3>Introduction</h3><p>While Excel might not be the most glamorous data analysis tool, it remains an indispensable and frequently demanded skill. For this project, I collected and analysed 37 articles and YouTube videos on the top Excel formulas used for data analysis. I employed Excel to see the most used or essential formulas Data analysts think.</p><h3>Data Collection</h3><p>I found 37 websites and YouTube videos about the top formulas used in data analysis. Most listed the top 10, some 15, 30, or even 50. I manually typed them in Excel and selected the first 10 formulas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BHya7sa3FXfD0YHe" /><figcaption>Raw data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*butg1wR-lo6qvSEx" /><figcaption>First 10 formulas</figcaption></figure><h3>Data preparation</h3><p>The data shape is long with multiple columns which is hard to analyse. I want all the formulas in one column. To unpivot the columns, I used Power query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HCJnKfGlLuFYxS38" /><figcaption>Go to <strong>Data</strong> and select <strong>Launch Power Query Editor</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L68vHcxBXlwQ4UIq" /><figcaption>Loaded the dataset, then in <strong>Transform, </strong>select all the columns and <strong>Unpivot columns</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SwAwK5lG3Rne0117" /><figcaption>To <strong>Home</strong>, <strong>Close &amp; load </strong>to save the unpivot table.</figcaption></figure><p>Now, it’s time for more formatting. First, a few cells show multiple formulas, such as <strong>LEFT/RIGHT</strong>, <strong>IF/IFS</strong> or <strong>MAX/MIN</strong>. I selected <strong>Data</strong> in the ribbon and chose <strong>Text to Column</strong> to separate the formulas using ‘/’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kWzm2Ew2tfsoXemI" /><figcaption><strong>Data</strong> &gt;<strong> Text to Column</strong> &gt; <strong>Delimited</strong> &gt; <strong>Delimited</strong>: Other⍁</figcaption></figure><p>Then, select all the blank cells using <strong>Find &amp; Select</strong> in <strong>Home</strong> Ribbon. Finally, right-click the selected array, click <strong>Delect</strong> and choose <strong>cells shift up</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PxjIGQGjA6i-gVfT" /><figcaption>Right click <strong>&gt; Delect &gt; Shift cells up</strong></figcaption></figure><p>After that, I cut and pasted these cells under the formula column. There are 409 cells.</p><h3>Data cleaning</h3><p>I used TRIM() to clear any extra space in the cell and found five typos (It was late at night.).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3zGbgJxNatCBKB2s" /></figure><p>There are two ways to find the unique values: the formula <strong>UNIQUE()</strong> or the Advanced in <strong>Data</strong> ribbon. After deleting NA, there are 75 unique formulas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MqvDjfsRrQSK-hwr" /><figcaption><strong>Data &gt; Advanced Filter &gt;</strong> choose <strong>Copy to another location</strong>, list range of cells, copy to the desired cell and tick <strong>Unique records only</strong></figcaption></figure><p>Now, <strong>COUNTIF()</strong> to see the final answer. With a click of the filter icon in the column Counts, you can see the top 10 formulas most used in data analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IC64-hf_6OQgAVnD" /></figure><h4>Top 10 formulas:</h4><ul><li>IF</li><li>VLOOKUP</li><li>CONCATENATE</li><li>SUMIFS</li><li>SUM</li><li>COUNT</li><li>COUNTIFS</li><li>AVERAGE</li><li>LEN</li><li>TRIM</li></ul><p>To explore this further, I categorised the formulas into 7 groups based on <a href="https://support.microsoft.com/en-au/office/excel-functions-by-category-5f91f4e9-7b42-46d2-9bd1-63f26a86c0eb">Mircosoft Excel</a>. I manually typed the formulas into categories, then <strong>XLOOKUP() </strong>the counts of the corresponding formulas. I also used Pivot Table charts to display the formulas based on their categories. However, I found Tableau to do the job better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iO2DCEFRUgvgyDot" /></figure><h3>Conclusion</h3><p>The statistical category has the most formulas, with 102 formulas, then the text category, with 97 formulas, and the third lookup &amp; reference, with 64 formulas. To explore the results of this project, please see my <a href="https://public.tableau.com/app/profile/ming.shan.lu/viz/Mostusedexcelformulasindataanalysis/Dashboard1#1">Tableau Dashboard</a>. If you want to play with this small dataset, I shared it at <a href="https://docs.google.com/spreadsheets/d/1GvW_fi2NqAiPMJZh8fSSlxKHImxEU1FL5a2zIt0DSxk/edit?usp=sharing">excel_formula_raw_data</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GKbh2iOPlyTs1Ch2" /><figcaption>Can you spot which top 10 formulas I used in this project??</figcaption></figure><p>Thank you for reading, and I hope you find this project interesting. Until next time, happy analysing!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58b3baeea219" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[E-Commerce Data Analysis SQL Project:]]></title>
            <link>https://medium.com/@ming.s.lu1617/e-commerce-data-analysis-sql-project-dc673b4348a2?source=rss-4822646f41ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc673b4348a2</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Ming S. Lu]]></dc:creator>
            <pubDate>Mon, 13 Nov 2023 04:28:50 GMT</pubDate>
            <atom:updated>2025-03-17T06:34:58.890Z</atom:updated>
            <content:encoded><![CDATA[<h4>Join Tables</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mXHMUh5qz0SxiyTu" /><figcaption>Photo Credit: <a href="https://www.bloomberglinea.com/english/olist-becomes-brazils-newest-unicorn-raises-186m/">Bloomberg Linea</a> Tiago Dalvi, founder and CEO of Olist</figcaption></figure><h3>Introduction</h3><p>How do you shop nowadays? Do you go to the physical store or check online first? I have been browsing for Christmas presents online recently and realised how e-commerce has changed how we shop without limitations of time and space. I am interested in how e-commerce operates differently in consumer culture. In this project, I will use the Olist e-commerce dataset on <a href="https://www.kaggle.com/datasets/olistbr/brazilian-ecommerce?rvi=1">Kaggle</a> to explore the information it provides.</p><h3>Dataset</h3><h4>Brazilian E-Commerce Public Dataset by Olist</h4><p>Since the dataset is provided by an actual online store called Olist in Brazil, I have a background check of the site. It was founded in 2015 by Tiago Dalvi.</p><p><a href="https://paganresearch.io/company/olist#:~:text=Olist%20operates%20an%20online%20e,small%20brick%20and%20mortar%20businesses">‘<em>Olist operates an online e-commerce site for sellers that connects merchants and their products to the main marketplaces of Brazil.</em>’</a></p><p>The dataset contains information on 100,000 orders made at multiple marketplaces in Brazil from 2016 to 2018. Its features allow viewing an order from multiple dimensions: from order status, price, payment and freight performance to customer location, product attributes, and customer reviews.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Pe-AuQ4D_FgaE5TF" /><figcaption>Data schema provided by Olist on Kaggle</figcaption></figure><h3>Data Preparation</h3><p>Always consider the schema and the table names before importing the data. I had learned them the hard way. I present them in a table format below with the data types changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sfSF6pOeCAd3fNVFl_sFZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z8aJh5-_Roj4POmq" /><figcaption>Note: in olist_order_review_dataset, I only imported the rows I will be needed.</figcaption></figure><p>There are nine tables, and it can be overwhelming when writing queries. That’s why I find the ER diagram so handy and helpful. As you can see below, it visually shows how the tables connect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OXsU7K60jtbTzL9A" /><figcaption>ER diagram of Olist dataset</figcaption></figure><p>I updated the <strong>olist_products </strong>to add the column ‘product_category_name_English’ from <strong>product_category_name_translation</strong> to make the upcoming queries more concise<strong>.</strong></p><p>Now, one less table to join.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hPPT-MMvLqwdptEl" /></figure><p>I also updated the empty spaces in ‘product_category_name’ and null values in ‘product_category_name_english’ to ‘N/A’. I updated two categories, ‘portable kitchens and food preparers’ and ‘pc-game’, in product_category_name_english’. In the end, there are 74 distinct product categories and 610 rows of ‘N/A’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xoav1P3epW4wsqG2" /></figure><h3>Data Analysis</h3><p>Writing readable SQL codes, especially when the queries become lengthy and complicated, is painless for self-documentation and more comprehensible for people who work with you. <strong>David Martins</strong>’s excellent article, ’10 <a href="https://medium.com/towards-data-science/10-best-practices-to-write-readable-and-maintainable-sql-code-427f6bb98208"><strong><em>Best Practices to Write Readable and Maintainable SQL Code,’</em></strong></a><strong><em> </em></strong>here on Medium, is worth reading. I will follow his guidelines and some of my own to write MySQL queries.</p><p>There are fourteen questions I will answer here:</p><ol><li>What is the total revenue generated by Olist, and how has it changed over time?</li><li>How many orders were placed on Olist, and how does this vary by month or season?</li><li>What are the most popular product categories on Olist, and how do their sales volumes compare to each other?</li><li>What is the average order value (AOV) on Olist, and how does this vary by product category or payment method?</li><li>How many sellers are active on Olist, and how does this number change over time?</li><li>What is the distribution of seller ratings on Olist, and how does this impact sales performance?</li><li>How many customers have made repeat purchases on Olist, and what percentage of total sales do they account for?</li><li>What is the average customer rating for products sold on Olist, and how does this impact sales performance?</li><li>What is the average order cancellation rate on Olist, and how does this impact seller performance?</li><li>What are the top-selling products on Olist, and how have their sales trends changed over time?</li><li>Which payment methods are most commonly used by Olist customers, and how does this vary by product category or geographic region?</li><li>How do customer reviews and ratings affect sales and product performance on Olist?</li><li>Which product categories have the highest profit margins on Olist, and how can the company increase profitability across different categories?</li><li>Geolocation has high customer density. Calculate customer retention rate according to geolocations.</li></ol><p>Q1: <strong><em>What is the total revenue generated by Olist, and how has it changed over time?</em></strong></p><p>First, I want to find the timeframe of the dataset. It is from <strong>2016–09–04</strong> to <strong>2018–10–17</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*15aVktaoCNZfpHQ6" /></figure><p>Then, there are eight types of <em>‘order_status’</em> in <strong>olist_orders</strong>. I considered the column <em>‘order_delivered_customer_date’ </em>to indicate the payment was valid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NpqJpiSSv0KoMGqz" /></figure><p>In the following analysis, I excluded the rows in ‘<em>order_status’</em> that are ‘canceled&#39; and ‘<em>order_delivered_customer_date</em>’ that are null. Therefore, the adjusted total revenue was $15.4 million.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hD3SYjmLhyjiQHqR" /></figure><p>Due to the dataset starting in September 2016, I started the sales trend analysis with the quarters and the months. We can see the revenue increased over time.</p><p><em>Sidenote:</em> It is better not to name the alias the same name as functions. When analysing time-related data, it always causes confusion when naming aliases as year, quarter, and month, which are all SQL functions. Here, I added ‘the_’ to avoid confusion. It is another good habit to maintain readable queries.</p><p>For quarterly analysis, it is also clear that the revenue was on continuous growth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ihp_PMh427EOeXdX" /><figcaption>Olist sales trend by quarters</figcaption></figure><blockquote>‘Black Friday is a colloquial term for the Friday after Thanksgiving in the United States. It traditionally marks the start of the Christmas shopping season in the United States. ‘</blockquote><blockquote>(Wikipedia).</blockquote><p>It seems that the Black Friday shopping fever was also happening to Brizal. You can see the graph on <a href="https://www.statista.com/statistics/779332/black-friday-e-commerce-sales-revenue-brazil/">Statista</a> on how revenue grows. For monthly sales, there were no sales records for 2016–11 and 2018–11, but the highest sales were in 2017–11. And besides September 2018, the monthly revenue in 2018 on Olist was over or close to one million.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dj7tB4SrjPsbZvcA" /><figcaption>Olist sales trend by months</figcaption></figure><p>Q2: <strong><em>How many orders were placed on Olist, and how does this vary by month or season?</em></strong></p><p>There were <strong>96,470</strong> orders placed on Olist. The results coincide with the sales trend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wM2DqRYF7bM1k0xg" /></figure><p>Since some months were missing in the seasons of 2016 and 2018, I added the years to see better results. The following are quarterly and monthly orders on Olist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6JTgrgmUVXBqVBGi" /><figcaption>Olist order numbers by quarters</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EpkLgwcN8TIPNlA6" /><figcaption>Olist order numbers by months</figcaption></figure><p><strong><em>Here, I will answer Question 3 and 10 together.</em></strong></p><p>Q3: <strong><em>What are the most popular product categories on Olist, and how do their sales volumes compare to each other? </em>Q10:<em> What are the top-selling products on Olist, and how have their sales trends changed over time?</em></strong></p><p>In the dataset description on Kaggle, it noted that an order might have multiple items and product_id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MpiRrqU7HUY48trt" /></figure><p>First, I calculated how many orders of product_id, and there were <strong>110,189</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r9guzJOWyBdf521n" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lOhtdjR8dORVm6Px" /><figcaption>olist_items table: one order can have multiple item_id and product_id</figcaption></figure><p>I CROSS JOIN the total counts of<em> ‘order_id’</em> to calculate the percentage of each product. The most popular products are <strong>bed_bath_table</strong>, <strong>health_beauty </strong>and <strong>sports_leisure</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3k93i82TWeJLlUaZ" /></figure><p>I added the ranking in descending order to see the products&#39; performance over the 3-year period. The products performed well over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-qcvBVcCUbo9Xgsy" /></figure><p>Q4: <strong><em>What is the average order value (AOV) on Olist, and how does this vary by product category or payment method?</em></strong></p><p><a href="https://www.optimizely.com/optimization-glossary/average-order-value/">AOV</a> is a crucial metric in understanding the performance of overall products compared to the cost per order (CPO). It allows a business to determine the performance of each product.</p><p>AOV = total revenue / total orders</p><p>CPO = total cost of product / total orders</p><p>I encountered duplicated rows, which occur very commonly when <a href="https://b-greve.gitbook.io/beginners-guide-to-clean-data/database-related-problems/table-joins">joining tables</a>. Before joining them, I first extracted the uniquely identified rows. I also double-checked the row numbers and the sum of the values within the joining tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uR98OMGqEyFiGCJa" /></figure><p>I will need product revenue to see how the average order value varies by product category. However, the data here provides only the revenue of orders and the cost of products. I count the profit orders and see their product categories.</p><p>I joined the query above as profit with the <strong>olist_items</strong> and <strong>olist_product</strong> tables to match the product categories. It is essential to distinguish that the count numbers here are not order numbers but product_id numbers. Products that have the most profit per order are bed_bath_table, furniture_decor, and telephony.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iiv8-X-hLZ067U8r" /><figcaption>Query of profit per order</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/0*lz-B2AvqD0rJpURj" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v7YTK4JQvk9wUlIQ" /><figcaption>Table of most profit products with order counts</figcaption></figure><p>For AOV by payment method, it showed credit card <strong>$162</strong> and boleto (ticket) <strong>$144</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PQ9f9c5sLj97K5Qb" /></figure><p>Q5: <strong><em>How many sellers are active on Olist, and how does this number change over time?</em></strong></p><p>The definition of active sellers might differ between marketplaces and the needs of businesses. Here, an active seller will be a seller who added a new listing in the last <a href="https://www.geckoboard.com/best-practice/kpi-examples/percentage-of-active-sellers/">30 days</a>. The query should be viewed from the inside out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S1zPjpEMw3A40cGd" /><figcaption>Total 3,095 seller_id</figcaption></figure><p>First, I realised some of the <em>‘order_id’</em> contained multiple <em>‘seller_ids’</em> in table <strong>order_item</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x8s5S9huAYEcyt49" /><figcaption>order_items table shows multiple seller_ids per order_id in some cases</figcaption></figure><p>To list the distinct <em>seller_id</em>, we need to do a form of self-join the <strong>order_items</strong> table using subqueries. The first subquery (subquery) calculates the count of distinct <em>seller_id</em>s for each <em>order_id</em>. This subquery is then joined back to the main <strong>olist_items</strong> table based on the <em>order_id</em>. The second subquery (si) retrieves the distinct <em>order_id</em> and <em>seller_id</em> pairs from the <strong>olist_items</strong> table. This subquery is then joined back to the main <strong>olist_items</strong> table based on the <em>‘order_id’</em>. This process is in the green square in the query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NaAX0zJtbiNltxXx" /><figcaption>Results of the distinct seller_ids pair with order_id</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/0*zxI8Q4sBN6J1LrLp" /></figure><p>After solving the duplicated seller_ids issue, I tried to find each seller’s last-second order date ( <em>‘order_purchase_timestamp’) </em>using the window function LAG() in the subquery <strong><em>second last order date</em></strong>. Then, I calculated the days between the last order and the one before, equal to or less than 30 in the subquery <strong><em>active_seller</em></strong>. Lastly, in the outer layer of the query, we had the number of active sellers: 1,786, which made up 58% of total distinct <em>seller_id</em>s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4gVuwzBxolieDmUF" /><figcaption>Table of the subquery pre_order_date</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h0mlfICtZWql-8n-" /><figcaption>Results of the subquery active_seller</figcaption></figure><p>I extracted the year, quarter, and month from the above query active_seller to see the change over time. It showed a steady increase in active sellers, especially a big jump in August 2018, when there were 1,003 active sellers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*NbB3hnpxqgXBuKyyFKg0Sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*77AI6jOYNaOa6rd0" /></figure><p>Q6: <strong><em>What is the distribution of seller ratings on Olist, and how does this impact sales performance?</em></strong></p><p>The <strong>olist_review</strong> table has 100,000 rows. There are 555 <em>‘order_id’ </em>with more than one review. I included all rows in the analysis. <strong>51%</strong> of the Olist customers are highly satisfied with the online shopping platform, rated Olist with the highest score of 5, and <strong>11%</strong> rated it 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KHqZm7o0__mTdZEA" /></figure><p>To join the correct rows in the tables, I created views of the <strong>review</strong> and <strong>payment </strong>tables and then joined the two tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AIdFe25zoKBt6A48" /><figcaption>View of review</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u7cWWhtFwNn6UlJ1" /><figcaption>View of payment</figcaption></figure><p>By joining review and payment, we had the revenue by review scores below. Over <strong>58%</strong> of revenue came from review_score of 5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RGeQk0vyeHBOthbwcDpbvA.png" /></figure><p>Q7: <strong><em>How many customers have made repeat purchases on Olist, and what percentage of total sales do they account for?</em></strong></p><p>Here, I first subtracted the customers that had repeat orders in the subquery and then counted the total number of repeat customers. There are <strong>2,801</strong> return customers, only <strong>2.9%</strong> of total customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8gW1Pvcvu2HS-N7L" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HD-cBkPbeS8ojxCC" /></figure><p>Then, I calculated the revenue of repeat customers was <strong>$864,357.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z1SriKdNSie5qKVA" /></figure><p>Finally, to determine the percentage of repeat customers’ revenue in total sales, I had two subqueries, ‘return_customers_revenue’ and ‘total_revenue’ in FROM to calculate the percentage of repeat customers. The result shows that only <strong>5.61 %</strong> of revenue was from customers returning for more purchases. <a href="https://medium.com/@Stan_DS/10-sql-best-practices-7ef8adbfd446">One article</a> mentioned it is better to use CTE instead of subqueries here. What do you think?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/0*B8JyrfGPdBvQfyxc" /></figure><p>Q 8: <strong><em>What is the average customer rating for products sold on Olist, and how does this impact sales performance?</em></strong></p><p>The average review score on Olist is <strong>4.1</strong>, which is excellent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ls5VaV98EGkEKd6t" /></figure><p>Intuitively, higher review scores encourage more purchases and vice versa. However, the results below show that order by the average review score for products does not match the ranking of order numbers. This is not to say the review score doesn’t matter, but the average of review scores on Olist is 4, which is 75% of all ratings. Therefore, I conclude that overall product sales on Olist show positive performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*57o4oZTb-JrjMyN5" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3qdtBYa8iO0O0J8N" /><figcaption>ORDER BY avg_review_score</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*igwgzIA1U5z4GxIe" /><figcaption>ORDER BY ranking</figcaption></figure><p>I also calculated the <a href="https://www.qualtrics.com/au/experience-management/customer/net-promoter-score/">Net Promoter score</a> as a reference to see the overall customer experience. The result was very positive, 64.76%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BMQNeGfywmle9gcT" /></figure><p>Q9: <strong><em>What is the average order cancellation rate on Olist, and how does this impact seller performance?</em></strong></p><p>Since the cancellation rate of <strong>0.63%</strong> is so low, there shouldn’t be a worry for Olist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IIFgPxW0JOlYSL4W" /></figure><p>Q11: <strong><em>Which payment methods are most commonly used by Olist customers, and how does this vary by product category or geographic region?</em></strong></p><p>The most commonly used payment method is a credit card.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zzpQO6pZ1Ch3K5hX" /></figure><p>For products, most payment types are credit cards. Here, I also selected the rows that were needed first before joining tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l4tJOecRrraQhLqE" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vfVYTpwHLUIB-dil" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eLABExqDkBFFtoa2" /><figcaption>ORDER BY product_name</figcaption></figure><p>And for geolocation, Sao Paulo had the most orders paid by credit cards, and Rio de Janeiro came next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FEOOlMFV0_l0gHSu" /></figure><p>Q12: <strong><em>How do customer reviews and ratings affect sales and product performance on Olist?</em></strong></p><p>To answer this question, I need the information on the sales price of <em>product_id</em>. However, <em>payment_value</em> in <strong>olist_payment </strong>was only present by <em>order_id</em>.</p><p>I analysed the profit by <em>order_id</em> and found only <strong>$2,831</strong> in profit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/0*Ysa2TJJbIxV0Sh58" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o0XoMOalX9r6oNKe" /><figcaption>Subquery profit table</figcaption></figure><p>Q13: <strong><em>Which product categories have the highest profit margins on Olist, and how can the company increase profitability across different categories?</em></strong></p><p>The data provides the revenue of orders and the cost of products. What I tried to find out first were the orders that had made profits. The results showed only 233 orders had made a profit. Upon further investigation, I checked the order id ‘6e5fe7366a2e1bfbf3257dba0af1267f’, which contained two product_ids and were two different products. In conclusion, I cannot find the highest profit in products due to the lack of information in the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hVQBGEqg7uH63hJk" /><figcaption>Table of profit orders</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mvF2Tja627pBKp_T" /><figcaption>Table of olist_items</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vbBIHUyvQmsYwoIb" /><figcaption>Table of olist_products</figcaption></figure><p>Q14: <strong><em>Geolocation has high customer density. Calculate customer retention rate according to geolocations.</em></strong></p><p>I used CTE to query the return customers and total number of customers. The top 10 states of CRR are shown in the table below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/0*NueIMu5PDjYG3KVU" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SPFWotOLXtHrcbov_Vm2dA.png" /></figure><h3><strong>Conclusion</strong></h3><p>Olist had raised <a href="https://www.bloomberglinea.com/english/olist-becomes-brazils-newest-unicorn-raises-186m/">$186 million</a> and became an unicorn company in 2021. From the datasets it provided from 2016 to 2018, there were little profits made. Still, increased revenue and orders of active sellers showed it was on the correct path to achieving its goal, which is connecting small businesses to larger product marketplaces to help entrepreneurs sell their products to a larger customer base.</p><p>The summary of Olist analysis:</p><ul><li>The revenue from 09/2016 to 10/2018 was <strong>15.4 million, </strong>and<strong> </strong>the orders from 09/2016 to 10/2018 were <strong>96,470</strong>.<strong> </strong>The sales<strong> </strong>continuously increased over time.</li><li>The average per order (AOV) was <strong>$160</strong>, and the cost per order (CPO) was also <strong>$160</strong>.</li><li>The most popular products were <strong>bed_bath_table, health_beauty, sports_leisure, furniture_decor, </strong>and<strong> computers_accessories</strong>.</li><li><strong>58%</strong> of sellers on Olist are active sellers. And they increased over time.</li><li><strong>2.9%</strong> of customers made repeat purchases; they obtained <strong>5.6%</strong> of the revenue.</li><li>The average review score on Olist was <strong>4</strong>, and NPS (Net promoter score) was <strong>65%.</strong></li><li>The average cancellation rate was <strong>0.63%.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dn3jeXprujjV4mIPdZpprw.png" /></figure><p>Thank you for reading.</p><p>Side note: The process of this project was both exciting and time-consuming. As a beginner of SQL, I was blindsided when a query successfully ran. After a lot of checking to ensure the results were accurate during the documentation, the biggest takeaway was that a query that runs does not mean the results were correct. Therefore, correctness and readability will be my priorities to improve my data analysis skills in SQL. Until next time, happy analysing.</p><p>Please check my <a href="https://github.com/ming-shan-lu/Olist"><strong><em>GitHub</em></strong></a><strong><em> </em></strong>to<strong><em> </em></strong>see MySQL code and <a href="https://public.tableau.com/app/profile/ming.shan.lu/viz/OlistE-commercePerformanceDashboard/Olist_dashboard"><strong><em>Tableau Public</em></strong></a><strong><em> </em></strong>for<strong><em> </em></strong>visualisation<strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc673b4348a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Data Analysis SQL Project:]]></title>
            <link>https://medium.com/@ming.s.lu1617/my-first-data-analysis-sql-project-bd4622a8ff1e?source=rss-4822646f41ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd4622a8ff1e</guid>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Ming S. Lu]]></dc:creator>
            <pubDate>Fri, 22 Sep 2023 03:44:57 GMT</pubDate>
            <atom:updated>2024-04-09T04:11:28.180Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploring the Airbnb Landscape: A Descriptive Analysis of Listings in Western Australia</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BsrlsvEerRjMn8OcjyVJPg.jpeg" /><figcaption>Photo Credit: Me (This is Albany)</figcaption></figure><h4><strong>INTRODUCTION</strong></h4><p>How do you choose your accommodation when travelling?? I went to some cities and chose Airbnb when travelling alone. However, I only went on Airbnb once in WA (Western Australia) when my family from overseas came to visit me. So, when I encountered this dataset from<a href="http://insideairbnb.com/"> <strong><em>Inside Airbnb</em></strong></a>, I was immediately intrigued. In this project, I will use MySQL and Tableau to explore, clean, analyse and present the Airbnb ecosystem in Western Australia.</p><h4><strong>Data Set</strong></h4><p>I admire the mission that Inside Airbnb has,</p><blockquote>Inside Airbnb is a mission-driven project that provides data and advocacy about Airbnb’s impact on residential communities.</blockquote><blockquote>We work towards a vision where communities are empowered with data and information to understand, decide and control the role of renting residential homes to tourists.”</blockquote><p>The website provides seven files for each city/ region. After viewing all of them, I chose ‘listings.csv’ for my first project, where the description says it summarised information and metrics for listings in WA. The bonus about this dataset is that Inside Airbnb provided the data <a href="https://docs.google.com/spreadsheets/d/1iWCNJcSutYqpULSQHlNyGInUvHg2BoUGoNRIGa6Szc4/edit#gid=1322284596"><strong><em>dictionary</em> </strong></a>for the detailed listing CSV file. So, let’s jump in to explore the dataset (I posted it on <a href="https://www.kaggle.com/datasets/mingslu/airbnb-wa"><strong><em>Kaggle</em></strong></a>) !!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VSASPh1wso4jbmb4" /></figure><h4><strong>Data Preparation</strong></h4><p>In my honest report, I had a hard time importing this dataset, as shown in my log below. After a considerable amount of time, I was finally able to import the CSV file into DBeavor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oOG4RxR60Z3tSA0a" /></figure><p>Before diving into the data, I checked the shape of the dataset. There are 18 columns and 11,507 rows in the dataset. Also, I changed column ‘<strong>host_id</strong>’ datatype from integer to VARCHAR(200) and ‘<strong>last_reveiw</strong>’ changed from VARCHAR(100) to date.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xz6a0h4Cw2FoTDAex6iX2A.png" /></figure><h4><strong>Data Analysis</strong></h4><p>I listed out initial questions I was interested in:</p><ul><li><strong><em>How many total listings are there in Western Australia?</em></strong></li><li><strong><em>Which areas have the most Airbnb Units in WA, and what is the price range?</em></strong></li><li><strong><em>Do hosts rent out their entire home or just a room?</em></strong></li><li><strong><em>Have hosts used Airbnb as a platform for long-term rental to avoid regulations or accountability?</em></strong></li></ul><h4><strong><em>How many total listings are there in Western Australia?</em></strong></h4><p>I realised there might be some inactive listings in the dataset. I considered inactive listings when columns ‘<strong>availability_365</strong>’ and ‘<strong>number_of_reviews’</strong> were equal to zero. I found 92 inactive listings. Since these listings are less than 1 % of the dataset, I did not exclude them in the following analysis. The total listings are <strong>11,507</strong> in WA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FvESAanfoy9hOpMD" /></figure><p>There are<strong> 6,320</strong> distinct hosts in Western Australia.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H7TumhvisqEkdXzz" /></figure><p>And now, let’s see how many listings these hosts have. With a quick check on Google, Exclusive Escapes and Let Go are property management agencies. Exclusive Escapes has two ‘<strong>host_id’</strong>, <strong>511967</strong> and <strong>34477031</strong>, to distinguish the ‘<strong>neighbourhood’</strong>. I will treat them as two different hosts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yLyyMFG7QQcAYfuh" /></figure><p>Follow up: I want to know how many of those hosts’ listings are more than one. First, I created a temporary table that contained a new calculated field, ‘<strong>percentage_of_total_listings’</strong>. Then, I filtered the total listings that were more than 1. And it showed that <strong>59.34%</strong> of hosts have more than 1 listing. People seem to use Airbnb as a business investment rather than the initial idea of sharing a space with travellers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rSKj9EfE1WCqJejk" /><figcaption>The temporary table contains the percentage of distinct hosts listings.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0W6CPHGWQ0X6zao2" /><figcaption>Percentage of hosts who have more than one listing</figcaption></figure><h4><strong><em>Which areas have the most Airbnb Units in WA, and what is the price range?</em></strong></h4><p>Of course, we want to know which areas are the most popular Airbnb destinations. There are <strong>112</strong> areas with Airbnb listings in WA, and the average price is <strong>$ 264</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6baz9EfH9vkTGpVr" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_B3r4-3ks7vKpi-j" /></figure><p>And here are the top 10 most listed areas in WA. It’s time to check out Busselton!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*aW5CqNXB5P7yc6Mdcfd82w.png" /></figure><p>The top 10 listed regions contained 51.03% of all listings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-Yot0ll1LxcK7kd_" /></figure><h4><strong><em>Do hosts rent out their entire home or just a room?</em></strong></h4><p>Continuing the above question about the price, I want to explore the price of different room types further. I can see that <strong>83%</strong> of listings are entire homes or apartments. Most of the Airbnb hosts do rent out their entire properties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gt0D9XSqnPcEZTRH" /></figure><p>How about the price in different areas? The highest-priced areas are not in the most listed areas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dw4uQ5vX8QiLD4tF" /></figure><p>When the data showed the neighbourhood of Waroona, it became clear that the price was skewed by ‘<strong>Camper RV in Lake Clifton</strong>’, which costs <strong>$10,000</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*w7zvePxHUV73pt0YyQokEg.png" /></figure><p>After excluding those four rows of data, I focus on the <strong>‘Entire Home/apt’</strong> price for different areas since they are the most room_type in WA. It shows the prices of those top 5 areas are all outback WA. (Please check this out with my <a href="https://public.tableau.com/app/profile/ming.shan.lu/viz/WA_airbnb/Dashboard1"><strong><em>Tableau Public</em></strong></a> dashboard with WA map.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MuO9Dxlcfx8G-0iM" /></figure><p>For hotel rooms,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qmqSqsAD_ZEAFJaw" /></figure><p>For private rooms, I found column ‘<strong>name’</strong> shows ‘hotel’ in some rows, but column <strong>‘room_type’</strong> is shown as ‘private room’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nFe7Whtn8m7GJz3j" /></figure><p>After eliminating those rows in which the <strong>‘name’</strong> column contains the word ’hotel’. We have a more precise result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7F1ixzIL7TAVASxl" /></figure><p>For shared rooms,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UriJBph_HZaIxrLISiXLUQ.png" /></figure><p>Are you as intrigued as I am when I see that Chittering has a shared room that costs <strong>$999</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GEkUydHEE-4HXKSYLF7rXQ.png" /></figure><h4><strong><em>Have hosts used Airbnb as a platform for long-term rental to avoid regulations or accountability?</em></strong></h4><p>A long-term rentals are <a href="https://trvlguides.com/articles/airbnb-short-term-long-term-rentals#whatislongtermairbnbrental"><strong><em>28</em></strong></a> days or longer. To determine whether it is a long-term listing, I looked at column ‘minimum_nights’. It is evident in WA that the answer to the question is no, <strong>98%</strong> of hosts in WA use Airbnb as a short-term rental.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N6eXd-vEeqKCCwf9" /></figure><h4><strong>Conclusion</strong></h4><p><a href="https://news.airbnb.com/en-au/more-space-for-your-money-airbnb-release-new-data-on-family-travel/#:~:text=As%20detailed%20in%20a%20new,in%20nearly%2090%2C0001%20destinations."><strong><em>Airbnb</em></strong></a> released an article about more and more family travel on its platform, which is up to 60% globally in 2022. In this WA Airbnb listing analysis report, I used MySQL to find the insight it can provide. The primary stakeholder is myself, who used Airbnb for solo travelling early on and now has a family. After the analysis, I have come to a better understanding of the ecosystem of Airbnb in WA. I also visualised the project by using <a href="https://public.tableau.com/app/profile/ming.shan.lu/viz/WA_airbnb/Dashboard1"><strong><em>Tableau Public</em></strong></a>.</p><p>To sum up the findings of this project:</p><ul><li>There are <strong>11,507 </strong>listings in Western Australia and <strong>6,320</strong> distinct hosts. However, the existence of property management agencies suggests more hosts than the results showed.</li><li>Nearly <strong>60% </strong>of the hosts have more than one listing. However, because property management agencies are included in the listings, the results might be lower than they showed.</li><li>Airbnb is listed in <strong>112</strong> areas in WA. The TOP 5 are Busselton, Margaret River, Stirling, Fremantle, and Mandurah, which contained <strong>36%</strong> of total listings.</li><li>The average price is <strong>$264. </strong>This information can be valuable for both hosts and guests in understanding market trends and setting pricing strategies.</li><li>The predominance of entire homes or apartments (<strong>83%</strong>) among Airbnb listings indicates hosts prefer to offer full accommodations rather than shared spaces or private rooms.</li><li><strong>97% </strong>of the listings provide short-term stays. This high percentage reflects primarily travellers seeking temporary lodging rather than long-term rentals.</li></ul><p>Thank you for sticking to the end. Hope you find the dataset about the city you live in<strong><em> </em></strong><a href="http://insideairbnb.com/"><strong><em>Inside Airbnb</em></strong></a> and have fun with it. Happy analysing!!</p><p>To see MySQL code, please check my<a href="https://github.com/ming-shan-lu/WA-airbnb/blob/main/README.md"> <strong><em>Github</em></strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd4622a8ff1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>