Forum Discussion
Topn with additonal filter
- Anonymous5 years ago
Hi MichalDe ,
Got it. I have reached your expected in two ways please check.
- Method 1:
1. Create a table:
Sum top10 table = SUMMARIZE('Date',"Top10", SUMX(TOPN(10, ALL(Customer[Full Name]),[Total Sales],DESC),[Total Sales]) )2. Create a measure:
Top 10 All Time = IF([Total Sales]=BLANK(),BLANK(),MAX('Sum top10 table'[Top10]))- Method 2:
1.Create a new Year table:
New Table = SELECTCOLUMNS(FILTER('Date',[Total Sales]<>BLANK()),"Year",[Year])2.Create new total sales measure:
new total sales = CALCULATE([Total Sales],FILTER('Date',[Year]=MAX('New Table'[Year])))3. Top10:
new top10 = SUMX(TOPN(10,ALL(Customer[Full Name]),[Total Sales],DESC),[Total Sales])The final output is shown below:
In addition, when I open your pbix file, an alert dialog shown :
It seems that your PBI is in an earlier version, so please upgrade it to the latest version and have a try.
Download Microsoft Power BI Desktop from Official Microsoft Download Center
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi MichalDe ,
Got it. I have reached your expected in two ways please check.
- Method 1:
1. Create a table:
Sum top10 table = SUMMARIZE('Date',"Top10", SUMX(TOPN(10, ALL(Customer[Full Name]),[Total Sales],DESC),[Total Sales]) )
2. Create a measure:
Top 10 All Time = IF([Total Sales]=BLANK(),BLANK(),MAX('Sum top10 table'[Top10]))
- Method 2:
1.Create a new Year table:
New Table = SELECTCOLUMNS(FILTER('Date',[Total Sales]<>BLANK()),"Year",[Year])
2.Create new total sales measure:
new total sales = CALCULATE([Total Sales],FILTER('Date',[Year]=MAX('New Table'[Year])))
3. Top10:
new top10 = SUMX(TOPN(10,ALL(Customer[Full Name]),[Total Sales],DESC),[Total Sales])
The final output is shown below:
In addition, when I open your pbix file, an alert dialog shown :
It seems that your PBI is in an earlier version, so please upgrade it to the latest version and have a try.
Download Microsoft Power BI Desktop from Official Microsoft Download Center
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- MichalDe5 years agoFrequent Visitor
Thanks a lot.
Method 1 works perfectly.
Stil wondering why in my measure, All(date[date]) function as a "filter2" embedded in CALCULATE statement doesn't change filter context for year in the raport table.