Skip to content

Total Sales vs Profit Margin, based on Grouping of Customers by a Percentile Ranking of Total Sales made

>> Download the sample (Power BI)

This sample compares Total Sales against profit margins, based on a discrete grouping of customers (e.g. Bottom, Middle and Top), according to their percentile ranking of total sales made.

Profit Margin =
DIVIDE ( [Total Profits], [Total Sales], 0 )

Ranking of Customers based on their Total Sales

Section titled “Ranking of Customers based on their Total Sales”
Ranking of Customers based on their Total Sales =
IF (
ISBLANK ( [Total Sales] ),
BLANK (),
RANKX (
FILTER ( ALL ( Customer_Table ), NOT ( ISBLANK ( [Total Sales] ) ) ),
[Total Sales],
,
ASC
)
)
Total Costs =
SUMX ( Sales_Table, Sales_Table[Unit Cost] * Sales_Table[Quantity] )
Total Profits =
[Total Sales] - [Total Costs]
Total Sales =
SUMX ( Sales_Table, Sales_Table[Unit Price] * Sales_Table[Quantity] )

Total Sales (Disaggregated into Groups based on the each Customers Percentile Ranking of Total Sales made)

Section titled “Total Sales (Disaggregated into Groups based on the each Customers Percentile Ranking of Total Sales made)”
Total Sales (Disaggregated into Groups based on the each Customers Percentile Ranking of Total Sales made) =
VAR RankingDimension =
VALUES ( Sales_Table[Customer] )
VAR TotalCustomers =
CALCULATE (
COUNTROWS ( Customer_Table ),
FILTER ( ALL ( Customer_Table[Customer] ), [Total Sales] > 0 )
)
VAR CustomerRank = [Ranking of Customers based on their Total Sales]
RETURN
CALCULATE (
[Total Sales],
FILTER (
RankingDimension,
COUNTROWS (
FILTER (
'Customer Grouped into Percentile Ranking Groups',
CustomerRank > TotalCustomers * 'Customer Grouped into Percentile Ranking Groups'[Low]
&& CustomerRank <= TotalCustomers * 'Customer Grouped into Percentile Ranking Groups'[High]
)
) > 0
)
)
Calendar_Table =
GENERATE (
CALENDAR ( DATE ( 2017, 1, 1 ), DATE ( 2019, 12, 31 ) ),
VAR currentDay = [Date]
VAR Day =
DAY ( currentDay )
VAR Month =
MONTH ( currentDay )
VAR Year =
YEAR ( currentDay )
RETURN
ROW ( "Day", day, "Month", month, "Year", year )
)