Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Letโs celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I could get the RankX working but I don't want to display the RankX measure in the matrix rather I want to add it to the filter pane of the visual. The problem is I can't tell if the results are sorted in ascending or descending or the Ranks are mixed. How do I get this working through DAX or better ask the user to dynamically select ASC or DSC
Here is my RankX function;
Solved! Go to Solution.
@ribs Hi!
First, create a new table with this code:
SortDirection =
DATATABLE("SortOrder", STRING, {{"ASC"}, {"DESC"}})
Second, update your measure:
Dynamic Rank =
VAR SelectJahr = SELECTEDVALUE(RankYearSelector[Year])
VAR SortOrder = SELECTEDVALUE(SortDirection[SortOrder])
VAR RevenueValue =
SWITCH(
TRUE(),
SelectJahr = 'From'[From Value], [Dynamic Revenue 1],
SelectJahr = 'To'[To Value 2], [Dynamic Revenue 2],
BLANK()
)
RETURN
SWITCH(
TRUE(),
SortOrder = "ASC", RANKX(ALLSELECTED(Customer[Name]), RevenueValue, , ASC, Dense),
SortOrder = "DESC", RANKX(ALLSELECTED(Customer[Name]), RevenueValue, , DESC, Dense),
BLANK()
)
Now, add your Dynamic Rank measure to the visual-level filter pane.
Set a condition like Dynamic Rank is less than or equal to 5 or whatever top N filter you want.
BBF
Thank you! That worked๐
@ribs Hi!
First, create a new table with this code:
SortDirection =
DATATABLE("SortOrder", STRING, {{"ASC"}, {"DESC"}})
Second, update your measure:
Dynamic Rank =
VAR SelectJahr = SELECTEDVALUE(RankYearSelector[Year])
VAR SortOrder = SELECTEDVALUE(SortDirection[SortOrder])
VAR RevenueValue =
SWITCH(
TRUE(),
SelectJahr = 'From'[From Value], [Dynamic Revenue 1],
SelectJahr = 'To'[To Value 2], [Dynamic Revenue 2],
BLANK()
)
RETURN
SWITCH(
TRUE(),
SortOrder = "ASC", RANKX(ALLSELECTED(Customer[Name]), RevenueValue, , ASC, Dense),
SortOrder = "DESC", RANKX(ALLSELECTED(Customer[Name]), RevenueValue, , DESC, Dense),
BLANK()
)
Now, add your Dynamic Rank measure to the visual-level filter pane.
Set a condition like Dynamic Rank is less than or equal to 5 or whatever top N filter you want.
BBF