Forum Discussion
DavidWaters100
Post Patron
6 years agoPrevious year values for current top 10
Hi, I am running below measure to return top 10 values for the current year. I also need to return the values of the previous year - but for the same top 10 in current year. I can't seem to ...
- 6 years ago
Try if this works for you.
Measure = VAR __selection = ALLSELECTED( 'Product'[ColorName] ) VAR __countSelection = COUNTROWS( __selection ) VAR __logical = IF( __countSelection > 10, 10, __countSelection ) VAR __topN = TOPN( __logical, __selection, [Sales Amount], DESC ) RETURN CALCULATE( [Sales Amount], KEEPFILTERS( __topN ), SAMEPERIODLASTYEAR( 'Date'[Datekey] ) )Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
LinkedIn
amitchandak
Super User
6 years agoDavidWaters100 , You might have measure like these
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
YTD QTY = TOTALYTD(Sum('order'[Qty]),'Date'[Date])
LYTD QTY = TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year))
Previous Year = CALCULATE(SUM('order'[Qty]), PREVIOUSYEAR('Date'[Date]))
create a rank on this year and filter top 10 or filter using top
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415