Forum Discussion
Adding a TOPN Filter to a Measure
- 4 years ago
Here is a more accurate representation that also works on line level.
SU Top10 = var mw = MAXX(all(Weekly),[YYYYWW]) var ft = filter(all(Weekly),[YYYYWW]=mw) var ms = SUMMARIZE(ft,[Short Name] ,"s",sum([Sales Units])) var tt = SELECTCOLUMNS(TOPN(10,ms,[s]),"Widget",[Short Name]) var mc = SUMMARIZE(Weekly,[Short Name] ,"s",sum([Sales Units])) var mf = filter(mc,[Short Name] in tt) return sumx(mf,[s])
Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. Screenshots of your source data are not useful.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
- LUCASM4 years agoHelper IV
Hi lbendlin
Thank you for your offer to help
I have created a sanatised file and a pbix file so you can see what I am trying to do.
I hope this helpsHere is a link to a OneDrive folder
https://1drv.ms/u/s!AgfQYi2RKbVJ41vWBFkOeunfki0h?e=C1XAf2
- lbendlin4 years agoSuper User
When you say "Top 10 (12 wks)" do you mean the top 10 for the entire range of 12 weeks, or do you want to consider all accounts that are in the Top 10 in each of the 12 weeks?
- LUCASM4 years agoHelper IV
Hi lbendlin
Apologise for the delay in responding
What I am attempting to do is CALCULATE the SUM(Volume) of ONLY the TOP 10 "Short Names" in the Latest Week over the last 12 weeks
DIVIDED BY
The Total SUM(Volume) over 12 weeks.
So Basically if you look at the Filters used to create the Top 10 Volume (12 Wks) - 302,717
can this be written as a Measure?
edit:
the confusing thing is that I only want to incude those products which appear in the current week top 10 and not what is the the real market share over 12 weeks.
This is because the table shows the current top 10 by volume and what their sales were over the last 12 weeks.
So the card above - in the pbix, needs to show the sum of the top 10 in the table
and then divide that top 10 by the Total