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
cwermager
Frequent Visitor

Running Total Based on Rank with Filters

Hi all.

 

I've scoured the forums for days to no avail. I'm no DAX expert, but have tried seemingly infinte variations of the proposed solutions. I'm trying to calculate a running total based on a rank using measures so I can filter by area. The example file in this post seemed most promising, but I still couldn't get it to work and it would only return the inidividual cost and not the running sum.

 

I have been able to get a Rank measure to work when filtering on one or multiple areas, but have stalled out on the running total.

 

RANK  = RANKX(ALLSELECTED(rv_WETS_LatestCache) , CALCULATE( DIVIDE(SUM(rv_WETS_LatestCache[OneYearBenefit]),sum(rv_WETS_LatestCache[JobCost]))),,DESC,Skip)

 

Here is some sample data. Each area has a variety of jobs that have a cost and benefit associated with them. The rank is calculated based on the efficiency, benefit/cost. I am trying to tally a cumulative cost based on the rank.

 

AreaJobIDCostBenefitEfficiencyRankCumulative Cost
A30010001500015.011000
A304150080005.345200
A30812001200010.022200
B3033000-4000-1.3915700
B301250050002.0812700
C3051500140009.333700
C306120050004.256400
C307200060003.068400
C302180040002.2710200

 

When filtering to a specific area I am trying to get the rank and cumulative cost to dynamically adjust. This is what I would expect:

 

AreaJobIDCostBenefitEfficiencyRankCumulative Cost
C3051500140009.311500
C306120050004.222700
C307200060003.034700
C302180040002.246500

 

Any help would be greatly appreciated.

 

Thanks.

Chad

3 REPLIES 3
FrankAT
Community Champion
Community Champion

Hi @cwermager 

I think you can do it like this:

 

02-11-_2020_23-00-11.png

 

Division = DIVIDE(MIN('Table'[Benefit]),MIN('Table'[Cost]))

Rank = RANKX(ALLEXCEPT('Table','Table'[Area]),[Division],,DESC,Skip)

 

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

Thanks @FrankAT. The rank is actually the one part that seems to be working. I am struggling to then take that rank to get a running cost total. 

I would not start such a complex task without a dimensional model. I suggest you creat a dimension table for the area and join it to your current table. Then use the new area column in your slicer and visual, and also change the reference in the measure. I don't know if that will fix it, but it is where I suggest you start. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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.