Forum Discussion
Adding a TOPN Filter to a Measure
I am rewriting this as I still dont have an answer and my original post has dried up.
I have the following cards
The top 50 is 297,219 / 436,661 = 68.1% of the Total for 1 week
However If I try a similar approach on the 3 month, I get
934,239 / 1,417,814 = 66.4% and it should be 65.9%
The 3 Month Total and 3 Months Top 50 are correctly calculated
To get the calculation to work I am attempting to create a measure which determins what the Top 50 Products are this month
and using that list calculate the sum of the last 3 months.
My Filters to calculate the Top 50 are set as
Where C_Unit Total =
C_Unit Total = CALCULATE (SUM('MyTable'[Sales Units]),
FILTER ('MyTable','MyTable'[Index_Month] = 1 || 'MyTable'[Index_Month] = 2 ||'MyTable'[Index_Month] = 3 )
)and C_Unit TW =
C_Unit TW = CALCULATE(
SUM(
'MyTable'[Sales Units]),
FILTER('MyTable','MyTable'[Index_Month] = 1)
)What I am guessing at this stage is that I need to add a FILTER to a new Measure C_Unit 3M that includes the Top 50 Short_Name by C_Unit TW
And that is where I am stuck
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])
14 Replies
- LUCASMHelper IV
Thank you for your explaination, that is worth a lot to me.
- lbendlinSuper User
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- LUCASMHelper 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
- lbendlinSuper 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?