Skip to content

Cumulative Sales, from best selling to lowest selling Product

>> Download the sample (Power BI)

This sample shows total cumulative sales, from the best-selling product to the lowest-selling product.

Cumulative Sales by Product, Ranked by Product Sales

Section titled “Cumulative Sales by Product, Ranked by Product Sales”
Cumulative Sales by Product, Ranked by Product Sales =
VAR IndexRank = 'Ranking Index'[Ranking Index Value]
VAR CumTotal =
SUMX (
FILTER (
SUMMARIZE (
Products_Table,
Products_Table[Products],
"Sales", [Total Sales],
"Sales Ranking", RANKX ( ALL ( Products_Table ), [Total Sales],, DESC )
),
[Sales Ranking] <= IndexRank
),
[Sales]
)
RETURN
IF ( [Product Sales, Ranked by Product Sales] = BLANK (), BLANK (), CumTotal )
Product Name Ranked by Sales =
CALCULATE (
SELECTEDVALUE ( Products_Table[Products], BLANK () ),
FILTER (
VALUES ( Products_Table[Products] ),
RANKX ( ALL ( Products_Table ), [Total Sales],, DESC ) = [Ranking Index Value]
)
)
Product Sales, Ranked by Product Sales =
CALCULATE (
[Total Sales],
FILTER (
VALUES ( Products_Table ),
Products_Table[Products] = [Product Name Ranked by Sales]
)
)
Total Sales =
SUMX ( Sales_Table, Sales_Table[Unit Price] * Sales_Table[Quantity] )
Ranking Index Value =
SELECTEDVALUE ( 'Ranking Index'[Ranking Index] )
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 )
)
Ranking Index =
GENERATESERIES ( 1, 200, 1 )