3. Macro Performance Analysis

Analysis of overall business performance metrics.

Introduction

In this section, we will answer the 23 business questions that we defined in the previous section using SQL queries and data analysis techniques. We will use the star schema that we created in the previous section to write SQL queries. Each question will be answered with a SQL query that retrieves the relevant data from the database, and we will also provide insights and interpretations of the results to help us understand the implications of our findings for the business.

The questions are designed in a way that they will help us to get business insights on the following domains:

  1. Makro Performance Analysis: Here we will analyze the overall performance of the business by looking at metrics such as total sales, profit, and customer count. We will also analyze the performance of different product categories and subcategories to identify trends and patterns in customer behavior. Questions 1-5 fall under this domain.
  2. Customer Behavior Analysis: In this domain, we will analyze customer behavior by looking at metrics such as customer demographics, purchasing patterns, and customer loyalty. We will also analyze the impact of different factors such as discounts and promotions on customer behavior. Questions 6-10 fall under this domain.
  3. Product Performance Analysis: Here we will analyze the performance of different products and product categories by looking at financial metrics such as Gross Profit, Gross Margin, Product Margin, and Sales Amount. We will also analyze the impact of different factors such as discounts and promotions on product performance. Questions 11-15 fall under this domain.
  4. Sales Reason and Customer Preference Analysis: In this domain, we will analyze the reasons behind sales and customer preferences by looking at metrics such as sales reasons, importance of promotional discounts, and preference of product categories. Questions 16-19 fall under this domain.
  5. Regional and Logistic Operations Analysis: Here we will analyze the performance of the business in different regions by looking at the Regional Preferences, Tax and Freight Costs, and Regional Bias for specific product categories. SLA and delivery performance will also be analyzed in this domain. Questions 20-23 fall under this domain.

For better clarity and organization, I will give a separate page for each domain and answer the relevant questions in that page. This way, we can focus on specific areas of analysis and gain deeper insights into each domain. As this is the first page of the SQL analysis section, we will start with the first domain, which is Makro Performance Analysis, and answer the first 5 questions related to that domain.

Macro Performance Analysis

Gross Profit and Gross Margin over Time

1. What is the overall Gross Profit and Gross Margin for the B2C channel, and how has it trended year over year?

Solution Method: To answer this question, we will write a SQL query that retrieves the Gross Profit and Gross Margin for the B2C channel from the fact table, and then we will group the results by year to analyze the trend over time. We will also calculate the year-over-year growth rate for both Gross Profit and Gross Margin to understand how they have changed over time. This requires simple select statements grouped by year and filtered by the B2C channel.

Show SQL Code
select
	c.CalendarYear as [year],
	round(sum(fis.SalesAmount),2) as total_revenue,
	round(sum(fis.TotalProductCost),2) as total_cost,
	round(sum(fis.SalesAmount) - sum(fis.TotalProductCost),2) as gross_profit,
	cast(100.0 * (sum(fis.salesamount) - sum(fis.TotalProductCost)) /
		nullif(sum(fis.SalesAmount), 0) as decimal(5,2)) as gross_margin_pct
from FactInternetSales fis
left join Calendar c
	on c.DateKey = fis.OrderDateKey
where c.CalendarYear not in (2010,2014)
group by c.CalendarYear
order by [year] asc;

Results:

yeartotal_revenuetotal_costgross_profitgross_margin_pct
20117075525.93004231462.19002844063.740040.20
20125842485.20003414478.17002428007.030041.56
201316351550.34009586139.37006765410.970041.37

Insights:

The overall Gross Profit for the B2C channel has shown a significant increase from 2011 to 2013, with a growth rate of approximately 138% from 2011 to 2013. The Gross Margin has also improved over the years, increasing from 40.20% in 2011 to 41.37% in 2013. This indicates that the B2C channel has been able to generate more profit from its sales while maintaining a healthy margin, which is a positive sign for the business. The increase in Gross Profit and Gross Margin could be attributed to various factors such as increased sales volume, better pricing strategies, or improved cost management. Further analysis would be needed to identify the specific drivers behind this growth.

Year-over-Year (YoY) Revenue Growth Rate

2. What is the Year-over-Year (YoY) revenue growth rate for each month?

Solution Method: To answer this question, we will write a SQL query that retrieves the revenue for each month from the fact table, and then we will group the results by month and year to calculate the Year-over-Year (YoY) revenue growth rate. We will use the LAG function to compare the revenue of each month with the same month in the previous year to calculate the growth rate. In order to prevent any duplication problem, we should use Common Table Expressions (CTEs) which helps us to organize our query and make it more readable as well as to avoid any potential issues with duplicate data when calculating the YoY growth rate.

Show SQL Code
with calculations as (
select
	c.CalendarYear as [year], 
	c.MonthNumberOfYear as month_number,
	c.MonthName as month_name,
	round(sum(fis.SalesAmount),2) as curr_total_revenue,
	lag(sum(fis.SalesAmount), 1) over (partition by c.MonthNumberOfYear 
		order by c.CalendarYear asc) as prev_total_revenue
from FactInternetSales fis 
join Calendar c 
	on c.DateKey = fis.OrderDateKey
	and c.CalendarYear not in (2010,2014)
group by 
	c.CalendarYear, 
	c.MonthNumberOfYear,
	c.MonthName
)

select
	[year], 
	month_number, 
	round(curr_total_revenue,2), 
	round(prev_total_revenue,2), 
	cast(100.0 * (curr_total_revenue - prev_total_revenue) / 
		nullif(prev_total_revenue, 0) as decimal(7,2)) as revenue_growth_pct
from calculations cal
order by [year], month_number;

Results:

yearmonth_numbercurr_total_revenueprev_total_revenuerevenue_growth_pct
20111469823.9100
20112466334.9000
20113485198.6600
20114502073.8500
20115561681.4800
20116737839.8200
20117596746.5600
20118614557.9400
20119603083.5000
201110708208.0000
201111660545.8100
201112669431.5000
20121495364.1300469823.91005.44
20122506994.1900466334.90008.72
20123373483.0100485198.6600-23.02
20124400335.6100502073.8500-20.26
20125358877.8900561681.4800-36.11
20126555160.1400737839.8200-24.76
20127444558.2300596746.5600-25.50
20128523917.3800614557.9400-14.75
20129486177.4500603083.5000-19.38
201210535159.4800708208.0000-24.43
201211537955.5200660545.8100-18.56
201212624502.1700669431.5000-6.71
20131857689.9100495364.130073.14
20132771348.7400506994.190052.14
201331049907.3900373483.0100181.11
201341046022.7700400335.6100161.29
201351284592.9300358877.8900257.95
201361643177.7800555160.1400195.98
201371371675.8100444558.2300208.55
201381551065.5600523917.3800196.05
201391447495.6900486177.4500197.73
2013101673293.4100535159.4800212.67
2013111780920.0600537955.5200231.05
2013121874360.2900624502.1700200.14

Insights: The Year-over-Year (YoY) revenue growth rate for each month shows significant fluctuations over the years. In 2012, there was a decline in revenue growth for most months compared to 2011, with some months experiencing a negative growth rate. However, in 2013, there was a substantial increase in revenue growth for all months compared to 2012, with some months experiencing a growth rate of over 200%. This indicates that the business experienced a significant recovery and growth in revenue in 2013 after a challenging year in 2012. The fluctuations in revenue growth could be attributed to various factors such as changes in market conditions, customer behavior, or the effectiveness of marketing and sales strategies. Or maybe the company launched better and became a more competitive player in the market in 2013, which led to a significant increase in revenue growth.

Seasonality of Sales and Quarterly Revenue Drivers

3. What is the monthly seasonality of our sales, and which quarter drives the most revenue historically?

Solution Method: To answer this question, I have written a SQL query that calculates the monthly revenue for each month and quarter, and then identifies the quarter that drives the most revenue historically. The query uses Common Table Expressions (CTEs) to organize the calculations and make it easier to read. The first CTE calculates the monthly revenue for each month and quarter, while the second CTE calculates the total revenue for each quarter. Finally, we calculate the growth rate of each quarter compared to the previous quarter to identify trends in seasonality. To prevent any duplication and wrong calculations, we have used CTEs in a sequence in which the financial metrics are derived first, then grouped by quarter, and then grouped with window functions get the previous quarter’s revenue for growth rate calculation.

Show SQL Code
with revenue_calculations as (
	select
		c.CalendarQuarter as [Quarter], 
		c.MonthNumberOfYear as month_number,
		c.MonthName as [Month],
		coalesce(sum(fis.SalesAmount),0) as revenue
	from FactInternetSales fis
	join Calendar c 
		on c.DateKey = fis.OrderDateKey
		and c.CalendarYear not in (2010, 2014)
	group by 
		c.CalendarQuarter, 
		c.MonthNumberOfYear,
		c.MonthName
),
curr_quarter_revenue_calc as (
	select
		[Quarter], 
		month_number,
		[Month], 
		revenue as monthly_revenue, 
		sum(revenue) over (partition by [Quarter]) as curr_quarter_revenue
	from revenue_calculations
),
growth_calc as (
	select
			[Quarter], 
			month_number,
			[Month], 
			monthly_revenue, 
			curr_quarter_revenue,
			lag(curr_quarter_revenue,3) over (order by [Quarter], month_number) as prev_quarter_revenue
	from curr_quarter_revenue_calc 
)

select 
	*,
	cast ((curr_quarter_revenue - prev_quarter_revenue) / nullif(prev_quarter_revenue,0) as decimal(10,2))
		as Q_revenue_growth_pct
from growth_calc
order by 
	[Quarter], 
	month_number;

Results:

Quartermonth_numberMonthmonthly_revenuecurr_quarter_revenueprev_quarter_revenueQ_revenue_growth_pct
11January1822877.95095476144.8363
12February1744677.83065476144.8363
13March1908589.05485476144.8363
24April1948432.23037089762.27105476144.83630.29
25May2205152.29657089762.27105476144.83630.29
26June2936177.74427089762.27105476144.83630.29
37July2412980.59497639278.10927089762.27100.08
38August2689540.87657639278.10927089762.27100.08
39September2536756.63787639278.10927089762.27100.08
410October2916660.89789064376.24787639278.10920.19
411November2979421.39029064376.24787639278.10920.19
412December3168293.95989064376.24787639278.10920.19

Insights: The monthly seasonality of our sales shows that the revenue tends to increase in the second and fourth quarters of the year, with the fourth quarter driving the most revenue historically. The growth rate of the second quarter compared to the first quarter is approximately 29%, while the growth rate of the fourth quarter compared to the third quarter is approximately 19%. This indicates that there is a significant increase in sales during these quarters, which could be attributed to various factors such as seasonal demand, holidays, or promotional activities. Understanding this seasonality can help us to plan our inventory, marketing campaigns, and staffing levels more effectively to capitalize on these peak periods and maximize our revenue.

Average Order Value (AOV) vs Total Order Volume (TOV)

4. What is the Average Order Value (AOV) for the B2C channel, and how has it trended over time?

Solution Method: This question is quite straitforward. We should calculate the Average Order Value (AOV) for the B2C channel by dividing the total sales amount by the number of distinct orders. We will group the results by year and month to analyze the trend over time. The query uses a simple aggregation to calculate the total sales amount and count of distinct orders, and then divides these two metrics to get the AOV for each month and year. I did not include the years - 2010 and 2014 in the analysis as they are incomplete years in our dataset, which could skew the results and provide an inaccurate representation of the AOV trend over time. By excluding these years, we can ensure that our analysis is based on complete data and provides a more accurate picture of the AOV trend for the B2C channel.

Show SQL Code
select
	c.CalendarYear calendar_year, 
	c.MonthNumberOfYear as month_number,
	count(distinct fis.SalesOrderNumber) as num_distinct_orders, 
	sum(fis.OrderQuantity) as num_items, 
	cast(sum(fis.SalesAmount) / nullif(count (distinct fis.SalesOrderNumber),0) as float)
		as avg_order_value
from FactInternetSales fis
join Calendar c
	on c.DateKey = fis.OrderDateKey
	and c.CalendarYear not in (2010, 2014)
group by 
	c.CalendarYear,
	c.MonthNumberOfYear
order by 
	calendar_year,
	month_number;

Results:

calendar_yearmonth_numbernum_distinct_ordersnum_itemsavg_order_value
201111441443262.666
201121441443238.4368
201131501503234.6577
201141571573197.9225
201151741743228.0544
201162302303207.9992
201171881883174.1838
201181931933184.238
201191851853259.9107
2011102212213204.5611
2011112082083175.701
2011122222223015.4572
201212522521965.7306
201222602601949.9776
201232122121761.7122
201242192191828.0165
201252072071733.7096
201263183181745.7866
201272462461807.1472
201282942941782.0319
201292692691807.3511
2012103133131709.7747
2012113243241660.3565
2012123554831759.161
2013163216621357.1042
2013214213453542.821
2013316904087621.2469
2013416123979648.8975
2013517924399716.8487
2013620075025818.7233
2013718754671731.5604
2013819664865788.9448
2013918844616768.3098
20131021315300785.2151
20131120875224853.3397
20131221925520855.0913

Insights: The Average Order Value (AOV) has shown a significant decline from 2011 to 2013. In 2011, the AOV was consistently above 3000,whilein2012,itdroppedtoaround3000, while in 2012, it dropped to around 1700-1900,andin2013,itfurtherdeclinedtoaround1900, and in 2013, it further declined to around 500-$800. This indicates that customers in the B2C channel are spending less per order over time. The decline in AOV could be attributed to various factors such as changes in customer behavior, increased competition, or the effectiveness of marketing and sales strategies. It is important for the business to analyze the underlying reasons for this decline and take appropriate actions to improve the AOV, such as offering promotions or bundling products to encourage customers to spend more per order. Conversely, the increase in the number of distinct orders and items sold over the years suggests that while customers are spending less per order, they are making more purchases overall, which could indicate a shift in customer behavior towards more frequent but smaller purchases. Toward the end of 2013, customers tend to buy more items per order, but spend less on average per order, which could indicate a shift in customer behavior towards more frequent but smaller purchases. Overall, that compensates for the decline in AOV and could be a positive sign for the business as it indicates that customers are still engaged and making purchases, even if they are spending less per order. However, it is important to monitor this trend closely and take appropriate actions to ensure that the business continues to grow and remain competitive in the market.

Year-to-Date (YTD) Revenue and Profitability

5. What is the Year-to-Date (YTD) revenue and profitability for the current year compared to the previous year?

Solution Method: I solved this question by using window function sum with order by day_number to calculate the cumulative revenue for each day of the year. The financial metrics are calculated in a CTE on a daily basis and then for the cumulative ytd calculations, sum window function is used.

Show SQL Code
with revenue_calculation as (
	select
		c.CalendarYear as calendar_year,
		c.MonthNumberOfYear as month_number,
		c.DayNumberOfYear as day_number,
		count(distinct fis.SalesOrderNumber) as num_orders,
		coalesce(sum(fis.salesamount), 0) as daily_revenue
	from FactInternetSales fis 
	right join Calendar c 
		on c.DateKey = fis.OrderDateKey
	where c.CalendarYear = 2013
	group by 
		c.CalendarYear,
		c.MonthNumberOfYear,
		c.DayNumberOfYear		
)

select
	*,
	sum(daily_revenue) over (order by day_number) as cumulative_revenue
from revenue_calculation r
order by 
	calendar_year,
	month_number,
	day_number

Results:

calendar_yearmonth_numberday_numbernum_ordersdaily_revenuecumulative_revenue
2013111529456.250029456.2500
201312612775.330042231.5800
2013131732708.450074940.0300
2013141527369.3400102309.3700
2013152132681.4400134990.8100
2013161521787.0200156777.8300
2013172343285.7400200063.5700
2013181522765.5900222829.1600
2013191729735.1400252564.3000
20131101627143.7400279708.0400
20131111930792.0700310500.1100
20131121424151.7200334651.8300
20131131629332.0600363983.8900
2013114916864.1700380848.0600
20131151317740.4800398588.5400
20131162443007.0600441595.6000
2013117910662.1000452257.7000
20131181729251.1300481508.8300
20131191527969.6300509478.4600
20131202846251.4900555729.9500
20131211524486.9700580216.9200
20131221837173.2900617390.2100
20131231520063.2400637453.4500
20131241621670.4100659123.8600
20131252546265.1100705388.9700
20131261221245.6500726634.6200
20131271832820.6000759455.2200
20131284622444.7800781900.0000
20131294317544.6500799444.6500
20131305434958.3200834402.9700
20131314623286.9400857689.9100
20132324210631.9600868321.8700
20132334631641.0400899962.9100
20132345839821.9000939784.8100
20132356741050.1100980834.9200
20132365136502.49001017337.4100
2013237369256.88001026594.2900
20132384323441.98001050036.2700
20132396138978.88001089015.1500
20132405327145.68001116160.8300
20132415522354.94001138515.7700
2013242388935.53001147451.3000
20132435524718.88001172170.1800
20132445630727.65001202897.8300
20132455243821.13001246718.9600
20132466332532.88001279251.8400
20132474222848.50001302100.3400
20132484722208.33001324308.6700
20132493316582.67001340891.3400
20132504123768.64001364659.9800
20132516438394.42001403054.4000
20132526534077.16001437131.5600
20132535233445.82001470577.3800
20132545516562.79001487140.1700
20132554929636.85001516777.0200
20132565633871.06001550648.0800
20132575330886.49001581534.5700
20132585225334.16001606868.7300
20132593622169.92001629038.6500
20133605839771.10001668809.7500
20133615239824.63001708634.3800
20133625827876.13001736510.5100
20133634437420.71001773931.2200
20133644634742.53001808673.7500
20133655730966.90001839640.6500
20133666236027.71001875668.3600
20133676439610.76001915279.1200
20133684531852.73001947131.8500
20133693722015.54001969147.3900
20133706438930.50002008077.8900
20133716755983.34002064061.2300
20133726036316.70002100377.9300
20133735431670.59002132048.5200
20133744722219.78002154268.3000
20133755025425.58002179693.8800
20133765832091.45002211785.3300
20133777257809.79002269595.1200
20133785946671.49002316266.6100
20133795423583.09002339849.7000
20133805141473.88002381323.5800
20133816036721.22002418044.8000
20133825125622.81002443667.6100
20133834431296.56002474964.1700
20133845428647.12002503611.2900
20133856238171.16002541782.4500
20133864722332.07002564114.5200
20133874022851.99002586966.5100
20133885430160.35002617126.8600
20133895223935.69002641062.5500
20133906737883.49002678946.0400
20134915431103.13002710049.1700
20134925034252.69002744301.8600
20134935840796.04002785097.9000
20134946944971.07002830068.9700
20134955425428.94002855497.9100
20134967745482.01002900979.9200
20134975439051.42002940031.3400
20134985527693.90002967725.2400
20134994639658.49003007383.7300
201341005237216.36003044600.0900
201341014834319.74003078919.8300
201341025737204.91003116124.7400
201341036337378.34003153503.0800
201341043726819.84003180322.9200
201341054836773.11003217096.0300
201341065945650.09003262746.1200
201341074539352.12003302098.2400
201341085322301.67003324399.9100
201341095334310.93003358710.8400
201341105743325.98003402036.8200
201341115938076.70003440113.5200
201341124517996.06003458109.5800
201341134827583.84003485693.4200
201341146544684.93003530378.3500
201341153931332.81003561711.1600
201341165535940.80003597651.9600
201341175627813.41003625465.3700
201341185236069.57003661534.9400
201341195336041.50003697576.4400
201341205127392.37003724968.8100
201351215938023.42003762992.2300
201351226949081.40003812073.6300
201351235828476.54003840550.1700
201351245332476.96003873027.1300
201351255238762.57003911789.7000
201351266039303.62003951093.3200
201351274128390.22003979483.5400
201351285546553.41004026036.9500
201351295852843.56004078880.5100
201351304118442.19004097322.7000
201351315536868.67004134191.3700
201351325836145.21004170336.5800
201351335736084.74004206421.3200
201351346141838.99004248260.3100
201351355238193.16004286453.4700
201351365941496.52004327949.9900
201351376239300.19004367250.1800
201351385743510.92004410761.1000
201351393926966.20004437727.3000
201351406238025.50004475752.8000
201351416558402.96004534155.7600
201351425438000.76004572156.5200
201351437261004.75004633161.2700
201351444435148.85004668310.1200
201351455542799.34004711109.4600
201351466250332.82004761442.2800
201351477553495.71004814937.9900
201351486245631.11004860569.1000
201351496233988.45004894557.5500
201351506663052.59004957610.1400
201351516751951.60005009561.7400
201361526262935.46005072497.2000
201361537151323.58005123820.7800
201361546455816.68005179637.4600
201361558172376.46005252013.9200
201361569177359.34005329373.2600
201361576947438.01005376811.2700
201361586146708.25005423519.5200
201361595228462.06005451981.5800
201361607157790.02005509771.6000
201361617269712.49005579484.0900
201361627959151.70005638635.7900
201361636160327.80005698963.5900
201361647957660.18005756623.7700
201361655636793.07005793416.8400
201361667049744.41005843161.2500
201361676967078.76005910240.0100
201361686463750.55005973990.5600
201361697167958.68006041949.2400
201361706663875.15006105824.3900
201361714334686.29006140510.6800
201361726954909.80006195420.4800
201361736643262.20006238682.6800
201361746851595.56006290278.2400
201361757260689.65006350967.8900
201361765848388.78006399356.6700
201361776154856.92006454213.5900
201361787753955.43006508169.0200
201361796059653.15006567822.1700
201361808058523.15006626345.3200
201361814426394.20006652739.5200
201371825942043.50006694783.0200
201371835646519.08006741302.1000
201371845439773.73006781075.8300
201371855738727.37006819803.2000
201371865935559.61006855362.8100
201371875953206.93006908569.7400
201371887549743.61006958313.3500
201371895135343.95006993657.3000
201371907348424.34007042081.6400
201371916648800.98007090882.6200
201371925046615.60007137498.2200
201371935041774.31007179272.5300
201371946645260.83007224533.3600
201371957050908.56007275441.9200
201371967543804.24007319246.1600
201371975230545.37007349791.5300
201371986229326.14007379117.6700
201371994934962.34007414080.0100
201372007559580.22007473660.2300

Insights: The Year-to-Date (YTD) revenue for the current year (2013) shows a steady increase over time, with cumulative revenue reaching approximately $7.47 million by the end of July. The profitability trend can be analyzed by comparing the daily revenue and cumulative revenue, which indicates that the business is generating consistent revenue growth throughout the year. The significant increase in revenue in June and July could be attributed to seasonal factors, promotional activities, or increased customer demand during these months. It is important for the business to continue monitoring the YTD revenue and profitability trends to make informed decisions about inventory management, marketing strategies, and resource allocation to sustain growth and maximize profitability.

Conclusion

The first domain is focused on analyzing the revenue growth, seasonality of sales, average order value, and year-to-date revenue and profitability for the B2C channel. According to the results of the SQL queries we derived following insights:

  • The Year-over-Year (YoY) revenue growth rate for each month shows significant fluctuations over the years, with a substantial increase in revenue growth in 2013 compared to 2012.
  • The monthly seasonality of sales indicates that the second and fourth quarters of the year drive the most revenue historically, with significant growth rates compared to the previous quarters.
  • The Average Order Value (AOV) for the B2C channel has shown a significant decline from 2011 to 2013, while the number of distinct orders and items sold has increased, indicating a shift in customer behavior towards more frequent but smaller purchases.
  • The Year-to-Date (YTD) revenue for the current year (2013) shows a steady increase over time, with significant growth in June and July, which could be attributed to seasonal factors or increased customer demand during these months. Overall, these insights provide valuable information for the business to make informed decisions about inventory management, marketing strategies, and resource allocation to sustain growth and maximize profitability in the B2C channel. It is important for the business to continue monitoring these trends and take appropriate actions to ensure continued growth and competitiveness in the market.