Forum Discussion
jopezzo
Helper I
7 years agoHow to filter a table based on a column's highest value
Hi,
I am trying to calculate the total quantity by Quality from a table called "Data", but filtering on the highest value in Period (in this case, 201906). The purpose is to calculate the variance for each quality (highest period/lowest period).
In other words, I would like to get for each product Quantity [Period 201906] / Quantity [Period 201902]
I have tried different formulas but I'm struggling with the filter context.
Can anyone help me?
Thanks!
- Anonymous7 years agoPlease use the same link as above.
Best
D.
8 Replies
- Greg_Deckler
Community Champion
Create a DAX formula that goes something like this:
Measure IsHighest = VAR __table = SUMMARIZE(ALLSELECTED('Table'),[Quality], [Period],"__Quantity",SUM([Quantity])) VAR __max = MAXX(__table,[__Quantity]) VAR __period = MAXX(FILTER(__table,[__Quantity] = __max),[Period]) RETURN IF(MAX([Period]) = __period,1,0)Then just fiilter on this being 1
- AnonymousNot applicableAgain, please resist the temptation to do it in DAX. Use Power Query because this is the right tool for the job.
Best
D.- jopezzo
Helper I
How would you proceed, then, with Query M?
- AnonymousNot applicable