Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
apollnor
Advocate II
Advocate II

Dynamic rank in DimTable based on Slicer and related FactTable

I have a stacked column chart that summarizes the invoiced hours (y-axis), with customers as column series (legend), over time (x-axis) 

Shared Axis: DimTime.MonthName
Column Series: DimCustomers.CustomerName

Column Values: FactInvoiced.InvoicedHours

 

The sorting horizontally is fine, January, February, etc. Because I've sorted the MonthName column by the MonthNumber column I also have available. The problem is the vertical sorting in the stacks of the column chart. I need to sort the customers based on how many invoiced hours there are on them so that the customer with the most hours is at the bottom of the column and then smaller and smaller as we go up the bar.

This is the formula I've used to create the calculated ranking column:

 

= RANKX(ALLSELECTED(DimCustomers);SUMX(RELATEDTABLE(FactInvoiced);FactInvoiced[Invoiced Hours]))

 

This works but it doesn't adapt to filtering I do on the FactInvoiced table. So when I want to see the ranking of customers but what it looks like when I filter on one of the employees in our company and the customers she has worked at, the ranking doesnt changed based on now narrower scope. 

 

What it looks like without any filters on the report (expected behaviour)What it looks like without any filters on the report (expected behaviour)What it looks like when I filter on one employee (Expected behavior would be a "re-rank" of the customers based on the avaiable data in the FactTable)What it looks like when I filter on one employee (Expected behavior would be a "re-rank" of the customers based on the avaiable data in the FactTable)

 

Do I need some form of relational filter in my DAX?

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

Hi @apollnor

 

Give this a shot please

 

=
RANKX (
    ALLSELECTED ( DimCustomers[CustomerName] );
    SUMX ( RELATEDTABLE ( FactInvoiced ); FactInvoiced[Invoiced Hours] )
)

Regards
Zubair

Please try my custom visuals

Gives an error regarding circular dependecy. 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.