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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
facilitydax
Frequent Visitor

Struggling with a Running Total Measure

I've been struggling with a Running Total measure for a while now.  The problem is that most examples of running total measures that are out there have to do with using a "column" as the sorting mechanism but I need to a measure.

1. In this example, I have the "RankTest" measure which is using a prioritization matrix to rank all my assets from 1-n. 

2. Next I have a restoration cost measure that is being calculated for every asset which is "Unconstrained_RM(SUM)".

 

However, as you can see I can't figure out how to create a measure for the running total in order by the RankTest.

runningTotalProblem.png

This is the current measure called Agg_Test5 that I've come up but it just replicates my UnconstrainedRMSum.

Agg_Test5 =
VAR currank = CALCULATE([RankTest], FILTER('AssetTable', SELECTEDVALUE('AssetTable'[AssetNumber])))
RETURN
CALCULATE (
SUMX('AssetTable', [UNCONSTRAINED_RM(SUM)]),
FILTER('AssetTable', [RankTest] <= currank),
ALL ('AssetTable'[AssetNumber])
)
Thanks in advance.  
1 ACCEPTED SOLUTION

Hi @facilitydax 

Try this. See it all at work in the attached file.

Running Total 2 = 
VAR currank2 = [RankTest]
RETURN
    CALCULATE (
        SUMX(Asset; [RM]);
        FILTER(ALL(Asset); [RankTest] <= currank2)
)

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
AlB
Super User
Super User

Hi @facilitydax 

Can you share the pbix? or a simplified version that reproduces the problem?

@AlB ,

Here's a highly modified version of the file with just the top 100 rows in one table. However, the concept is the same in that I need to be able to do the Running Total correctly.

 

Asset Running Total Problem

 

Thanks!

Hi @facilitydax 

Try this. See it all at work in the attached file.

Running Total 2 = 
VAR currank2 = [RankTest]
RETURN
    CALCULATE (
        SUMX(Asset; [RM]);
        FILTER(ALL(Asset); [RankTest] <= currank2)
)

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

Hi @AlB ,

Can't thank you enough for the help so far. It does indeed work in that stripped down troubleshooting file. Unfortunately, I can't verify whether it works in my full larger file model because it exceeds my memory after a minute or so.  It's kind of a bummer because the rank measure and the unconstrainedRM measure render just fine until I try to throw the new running total into the table.

 

If you have any ideas on why it won't finish, give me a holler.

 

Thanks! 

Hard to tell without seeing the real file. Can you show at least the structure of your tables? How many rows do they have? How much memory does your computer have? 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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