Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all,
I have created a measure that calcualtes the differences between the two dates as defined by the slicer, 'between' category. The measure is below:
measureDiff =
var _max = maxx(ALLSELECTED('Date'),'Date'[Date])
var _min = minx(ALLSELECTED('Date'),'Date'[Date])
var _sumMax =
SUMX(
FILTER(Analysis, Analysis[Date] = _max),
Analysis[pct]
)
var _sumMin =
SUMX(
FILTER(Analysis, Analysis[Date] = _min),
Analysis[pct]
)
Return
_sumMax - _sumMin
What i am struggling with, is how to update the same measure so that i can create a table of top5/bottom5 by the different categories that I choose from my dataset. The key thing for this is for it to be dynamic, so i cna change my date ranges and pick different columns as I see fit.
hey - I will give this a try later this week - apols for the delay and appreciate your assistance in the matter.
Hi @asmirnoffnorth ,
We can create a measure.
DynamicRank =
VAR SelectedCategory = SELECTEDVALUE(YourCategoryTable[CategoryColumnName])
VAR RankValue =
RANKX (
ALLSELECTED ( YourCategoryTable[CategoryColumnName] ),
CALCULATE (
[measureDiff],
YourCategoryTable[CategoryColumnName] = SelectedCategory
)
)
RETURN
IF (
RankValue <= 5 || RankValue >= COUNTROWS ( ALLSELECTED ( YourCategoryTable[CategoryColumnName] ) ) - 4,
[measureDiff]
)
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey,
can you just explain what your measure does? it doesn't seem to return me a table of the top/bottom 5s, but the whole table like i've already got. i've used the "dynamicRange" in the "values" category under vizualizations. is that the right way to use this measure? thanks again!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 36 | |
| 28 | |
| 28 |
| User | Count |
|---|---|
| 124 | |
| 88 | |
| 74 | |
| 66 | |
| 65 |