- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Rankx on virtual tables return only 1
Hello guys
I am trying within one measure to generate the ranking by country based on ACT vs BUD.
The fact table and the dimension table DimEntities are connected in the model.
The fact table has only one column with the values, and one column to differenciate the scenario (so ACT, BUD etc).
I understand that RANKX works in row context, so i barely can use it on already existing measures. That is why i am trying to build these virtual tables.
I understood as well that to calculate ACT - BUD, they have first to be created in a first virtual table.
Now i am getting nuts, because whatever i do, i get the ranking "1" for all countries.
Here is the DAX code i use:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi guys
I think i found the solution:
My inspiration came from this post:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi guys
Following this idea
This measure is now working:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi guys
I think i found the solution:
My inspiration came from this post:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Glad you could resolve it.
RANKX is simple function but not easy to use.
I am adding for others future reference and for you also:
I believe you are looking to calculate rank dynamically based on multiple (table) columns.
You can check this article for more understanding:
https://www.sqlbi.com/articles/rankx-on-multiple-columns-with-dax-and-power-bi/
Section: Dynamic ranking on Rounded Sales and customer name
https://www.sqlbi.com/articles/introducing-rankx-in-dax/
https://blog.enterprisedna.co/rankx-dax-function-in-power-bi-a-comprehensive-overview/
I am still puzzled , whether this approach works or not in your scenario:
- I am using AdventureWorks Sales as example.
- Sales table has transactions, dimensions are Product, Sales Territory and linked to Sales table
I created Profit measure as below
I created rank measure as below
Rank Profit By Product Category By Sales Territory Country =
IF ( HASONEVALUE('Product'[Category]) && HASONEVALUE('Sales Territory'[Country]) && not ISBLANK(Sales[Profit]),
RANKX ( ALLSELECTED(Sales), CALCULATE( [Profit], ALLEXCEPT(Sales, 'Product'[Category], 'Sales Territory'[Country])) , , DESC, DENSE)
)
I see the output as below
🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I am now trying my luck with the no so communicated function "RANK", without "X".
If somebody has ideas there...
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@Ghuiles, Try like
rankx(
SUMMARIZE(
allselected('Fact'),
'Fact'[Date],
'Fact'[Entity],
DimEntities[Country]), CALCULATE( SUM('Fact'[Value]), 'Fact'[Scenario]= "Actual")- CALCULATE(SUM('Fact'[Value]), 'Fact'[Scenario]= "Budget"),,desc,dense)
Power BI Rank Across dimension tables: https://youtu.be/X59qp5gfQoA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi
Thanks amitchandak!
Unfortunately it does not solve the problem.
Somehow the ranking is now from 1 to 4.
Any idea how i could debug this?
I am trying further based on your idea.
Cheers
G.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

To debug, you can see what is the data coming upto here, like creating dax table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

nice, but still not working 😞
At the end, i need to have it in working measure.
Going now to bed. Perhaps tomorrow will solve it. Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi guys
Following this idea
This measure is now working:

Helpful resources
User | Count |
---|---|
134 | |
124 | |
84 | |
61 | |
46 |