Skip to content

Profit Margins vs Sales, based on Customer Grouping by Total Profits

>> Download the sample (Power BI)

This sample compares profit margins and Total Sales, based on a discrete grouping of customers (e.g. Good Clients, Ok Clients, Poor Clients and Top Clients), depending on each customer’s total profit.

It does this in two ways:

(i) Where the grouping of customers is predetermined as a calculated column in the Customer table

(ii) Where the grouping of customers is determined on the fly with dynamic measures, so that it responds to any page filters that might also be applied

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

Profit Margins (Disaggregated into Groups based on each Customers Total Profit)

Section titled “Profit Margins (Disaggregated into Groups based on each Customers Total Profit)”
Profit Margins (Disaggregated into Groups based on each Customers Total Profit) =
VAR RankingDimension =
VALUES ( Customer_Table[Customer] )
RETURN
CALCULATE (
[Profit Margin],
FILTER (
RankingDimension,
COUNTROWS (
FILTER (
'Customer Total Profit Groups',
[Total Profits] >= 'Customer Total Profit Groups'[Min]
&& [Total Profits] < 'Customer Total Profit Groups'[ Max ]
)
) > 0
)
)
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 each Customers Total Profit)

Section titled “Total Sales (Disaggregated into Groups based on each Customers Total Profit)”
Total Sales (Disaggregated into Groups based on each Customers Total Profit) =
VAR RankingDimension =
VALUES ( Customer_Table[Customer] )
RETURN
CALCULATE (
[Total Sales],
FILTER (
RankingDimension,
COUNTROWS (
FILTER (
'Customer Total Profit Groups',
[Total Profits] >= 'Customer Total Profit Groups'[Min]
&& [Total Profits] < 'Customer Total Profit Groups'[ Max ]
)
) > 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 )
)