Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I have two dimensions and a fact as below for example:
Dimensions with columns in brackets
================================
D1 (C1)
D2(C2)
Fact
============
F(FC1)
Relationship
==========
Both Dimensions connect to the Fact on a one-to-many lets say the foreign keys in the Fact are D1F and D2F.
My measure
R =
Solved! Go to Solution.
OK, this measure does it for any combination of colour and garment:
Rank =
var CurrentPrice = [Total Price]
var CurrentPriceIsNotBlank = NOT( ISBLANK( CurrentPrice ) )
return
if( CurrentPriceIsNotBlank,
var ColorInScope = ISINSCOPE( Colour[Colour] )
var GarmentInScope = ISINSCOPE( Garment[Garment] )
return
SWITCH( TRUE(),
ColorInScope && GarmentInScope,
var TableToRankOverWhenBothInScope =
CALCULATETABLE(
ADDCOLUMNS(
SUMMARIZE(
F,
Garment[Garment],
Colour[Colour]
),
"@TotalPrice", [Total Price]
),
ALLSELECTED( F )
)
var Result =
RANKX(
TableToRankOverWhenBothInScope,
[@TotalPrice],
CurrentPrice,
DESC, Dense
)
return
Result,
ColorInScope,
RANKX(
ALLSELECTED( Colour[Colour] ),
[Total Price],
CurrentPrice,
DESC, Dense
),
GarmentInScope,
RANKX(
ALLSELECTED( Garment[Garment] ),
[Total Price],
CurrentPrice,
DESC, Dense
)
)
)
So, you can rank using this measure either the colours, or the garments or both at the same time. Here's the model I created:
When creating models make sure that they do not have referential integrity issues. Otherwise you'll be hunting subtle bugs. [Total Price] is just the old plain sum over F[Price].
Here's the partial solution to the problem of drillthrough and relative ranking as promised. Please, study the solution carefully and in depth. You'll have to understand it to adjust it to your model. You'll need to replicate some of the Garment table to achieve what you want. Take a good look at which columns from which tables have been put in which visuals. This is of utmost importance. And remember that table that should not be visible in the UI should always be hidden not to confuse users.
https://1drv.ms/u/s!ApyQEauTSLtOgZlS0EJO8F29gGxgPQ?e=MG9c9n
Hi there, @TopHat.
As mentioned, I've found a fully dynamic and general solution but it requires some DAX wizardry and for the time being I only have a sketch, not yet fully functional. I'll work on this and once a full general solution is assembled, I'll place a link to the file in here. Please bear with me. Thanks.
OK, this measure does it for any combination of colour and garment:
Rank =
var CurrentPrice = [Total Price]
var CurrentPriceIsNotBlank = NOT( ISBLANK( CurrentPrice ) )
return
if( CurrentPriceIsNotBlank,
var ColorInScope = ISINSCOPE( Colour[Colour] )
var GarmentInScope = ISINSCOPE( Garment[Garment] )
return
SWITCH( TRUE(),
ColorInScope && GarmentInScope,
var TableToRankOverWhenBothInScope =
CALCULATETABLE(
ADDCOLUMNS(
SUMMARIZE(
F,
Garment[Garment],
Colour[Colour]
),
"@TotalPrice", [Total Price]
),
ALLSELECTED( F )
)
var Result =
RANKX(
TableToRankOverWhenBothInScope,
[@TotalPrice],
CurrentPrice,
DESC, Dense
)
return
Result,
ColorInScope,
RANKX(
ALLSELECTED( Colour[Colour] ),
[Total Price],
CurrentPrice,
DESC, Dense
),
GarmentInScope,
RANKX(
ALLSELECTED( Garment[Garment] ),
[Total Price],
CurrentPrice,
DESC, Dense
)
)
)
So, you can rank using this measure either the colours, or the garments or both at the same time. Here's the model I created:
When creating models make sure that they do not have referential integrity issues. Otherwise you'll be hunting subtle bugs. [Total Price] is just the old plain sum over F[Price].
Thanks for that, it's perfect.
What would you have to do if you wanted to find what the rank of a certain Garment & Colour is and show it in a card please?
I am looking to use Drillthrough to show the Rank in a Card of the selected Garment & Colour.
I have mocked this up:
When I add Colour from table D2 I get the below:
What I am after:
I am not being able to use D2 in the RANKX to take that into account.
Hope that is a bit clearer.
Thanks
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 17 | |
| 8 | |
| 8 | |
| 7 |