Skip to content

Max Sales for a Product & Region combination, using the GROUPBY function

>> Download the sample (Power BI)

This sample shows the maximum total sales for a particular customer, for a particular product and region combination.

Max Sales by Product by Region =
VAR ProductRegions =
GROUPBY (
Sales_Table,
Products_Table[Products],
Region_Table[Region],
"Sales", SUMX ( CURRENTGROUP (), Sales_Table[Quantity] * Sales_Table[Unit Price] )
)
RETURN
MAXX ( ProductRegions, [Sales] )
Total Revenue =
SUMX ( Sales_Table, Sales_Table[Quantity] * Sales_Table[Unit Price] )
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 )
)
Sales Per Product by Region =
GROUPBY (
Sales_Table,
Products_Table[Products],
Region_Table[Region],
"Sales", SUMX ( CURRENTGROUP (), Sales_Table[Quantity] * Sales_Table[Unit Price] )
)