top of page

Multi-Dimensional KPI Calculation on Sales

Requirement

Introduction: Analyzing sales performance across multiple dimensions, such as region, product, and time, is essential for understanding business trends and making informed decisions. To calculate advanced Key Performance Indicators (KPIs), including product rankings and sales growth trends. Deeper insights into sales patterns across different regions and products, enabling data-driven strategies to enhance overall performance and drive success in the sales.

 

Requirements:

 

Create the Pyspark code and use the source table ‘sales_window'.

 

Total_Sales: Calculate the Total Sales_Amount and Average Sales_Amount by Region and Product.

 

Sales_Trends: Calculate the change in sales ‘Sales_Change' by group by ‘Region’ and 'Product’ and order by quarter with column of ‘Previous_Sales_Amount' and 'Sales_Change’ by difference of Sales_Amountby Previous_Sales_Amount .

 

Final_KPI: Aggregate the KPI’s Join the resuls of Total_Sales_Region and Top_Selling_Products and Sales_Trends.

 

Final Output: Show the results of Total_Sales, Sales_Trends, Final_KPI separately.

 

Unity Catalog: purgo_playground.sales_window

Purgo AI Agentic Code

bottom of page