How to create
A Top 5 Measure
in Power BI
Top 5 in a Measure
Although Power BI has
an built-in Top N filter
feature
It is often useful to be
able to show that value
as a measure and what
percent of the whole it
represents
This guide shows you
how to do it
Step by Step
Create a measure to
aggregate sales for the
top 5 products
We create a Variable to
identify the top 5
products, and a
separate variable to
aggregate the sales
amount
This makes the DAX
easier to follow
Top 5 Products Sales =
VAR TopNProducts =
TOPN (
5,
SUMMARIZE(Sales,
'Product'[Product],"SALESVALUE",sum(Sales[Sales Amount])),
[SALESVALUE],desc
)
VAR Result =
CALCULATE (
SUM(Sales[Sales Amount]),
TopNProducts
)
RETURN Result
DAX Breakdown
SUMMARIZE creates subtotals, in this case a column with each ‘Product’
and a second column for the total sales
SUMMARIZE(Sales, 'Product'[Product],"SALESVALUE",sum(Sales[Sales
Amount]))
TOPN – The ‘5’ sets how many top rows to return
We use the summarise row to define the data rows (see above)
The last row defines the field to sort by (SALESVALUE in Descending order)
TOPN (
5,
SUMMARIZE(Sales, 'Product'[Product],"SALESVALUE",sum(Sales[Sales
Amount])),
[SALESVALUE],desc
DAX Breakdown
Next we calculate the Sum of Sales for each Product in the Top N products
VAR Result =
CALCULATE (
SUM(Sales[Sales Amount]),
TopNProducts
)
Top X in a Measure
We have then used this
measure on a card to
highlight how much of the
total the top X products
represent
We added a simple
secondary measure showing
what percentage this is
We then created similar for
the bottom 20 products
And Finally added these to
the chart
Hope you find these useful
For more Tips, Tricks and
Timesavers, visit our website
Tips and Timesavers | Select Distinct Limited
Credit: simon.harrison@selectdistinct.co.uk

Power BI Tips Top N Measures.pptx

  • 1.
    How to create ATop 5 Measure in Power BI
  • 2.
    Top 5 ina Measure Although Power BI has an built-in Top N filter feature It is often useful to be able to show that value as a measure and what percent of the whole it represents This guide shows you how to do it
  • 3.
    Step by Step Createa measure to aggregate sales for the top 5 products We create a Variable to identify the top 5 products, and a separate variable to aggregate the sales amount This makes the DAX easier to follow Top 5 Products Sales = VAR TopNProducts = TOPN ( 5, SUMMARIZE(Sales, 'Product'[Product],"SALESVALUE",sum(Sales[Sales Amount])), [SALESVALUE],desc ) VAR Result = CALCULATE ( SUM(Sales[Sales Amount]), TopNProducts ) RETURN Result
  • 4.
    DAX Breakdown SUMMARIZE createssubtotals, in this case a column with each ‘Product’ and a second column for the total sales SUMMARIZE(Sales, 'Product'[Product],"SALESVALUE",sum(Sales[Sales Amount])) TOPN – The ‘5’ sets how many top rows to return We use the summarise row to define the data rows (see above) The last row defines the field to sort by (SALESVALUE in Descending order) TOPN ( 5, SUMMARIZE(Sales, 'Product'[Product],"SALESVALUE",sum(Sales[Sales Amount])), [SALESVALUE],desc
  • 5.
    DAX Breakdown Next wecalculate the Sum of Sales for each Product in the Top N products VAR Result = CALCULATE ( SUM(Sales[Sales Amount]), TopNProducts )
  • 6.
    Top X ina Measure We have then used this measure on a card to highlight how much of the total the top X products represent We added a simple secondary measure showing what percentage this is We then created similar for the bottom 20 products And Finally added these to the chart
  • 7.
    Hope you findthese useful
  • 8.
    For more Tips,Tricks and Timesavers, visit our website Tips and Timesavers | Select Distinct Limited Credit: simon.harrison@selectdistinct.co.uk