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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
kcdistiller
Frequent Visitor

Calculate Running Total Using Input from Another Calculation (Measure)

There are many solutions to calculate a running total based on dates or counts within a table, but I have not found a way to create a running total measure using input from another measure. Consider the following visualization table:

 

Column AColumn BColumn CColumn D
Unique_ID (table data)Medication (table data)Percent_Contributed (calculated)Percent_Running_Total (desired calculation: same row, column C + prior row, column D)
7980Penicillin G17.7717.77
723Amoxicillin5.7923.56
2670Codeine4.2327.79
1191Aspirin2.4930.28
10831SMZ/TMP2.4732.75
7052Morphine2.3735.12

 

Columns A and B are text fields identifying unique items. Column C is a measure resulting from a calculated numerator and denominator [(amount for unique entry/amount for all unique entries) * 100]. 

 

I'm trying to use a measure to populate Column D in a visualization table with a running total using info from Column C, but all methods appear to rely on info in the data table(s).

5 REPLIES 5
Anonymous
Not applicable

Hi @kcdistiller

 

It is possible to do it without a calendar table also.

 

I am assuming your UniqueID ( Column A) and Medication Data ( Column B) are coming from the same table.

 

Try this for column D , where you need the running total of column C

 

Define a measure RunningTotC 

 

RunningTotC =  Calculate([measureCoumnC],
                                                        FIlter(

                                                                    ALL(SourceDataTable),
                                                                          (SourceDataTable[ColumnA])<=MAX(SourceDataTable[CoulmnA])
                                                                  )

                                                                     )

 

 

The highlighted area above can also be changed to take a concatenation of Column A and Column B

as 

  ( SourceDataTable[ColumnA]&"-"&SourceData[ColumnB]<=MAX(SourceDataTable[ColumnA]&"-"&SourceData[ColumnB])

 

If this works for you please accept it as a solution and also give KUDOS.

 

Cheers

 

CheenuSing

Your suggestion calculates something, but not what is expected. If there is a way to use 'EARLIER' in place of 'MAX' in your recommended code, I think it would work. However, I get an error saying that "'EARLIER' refers to a row context which dosen't exist'. This is likely due to 'Percentage' being a measure, not an actual value in a table. If I change the measure to a calculated column, I lose the ability to update the value based on slicers. Ideally, the code would probably look like

 

RunningTotC = CALCULATE([Percentage],Filter(ALL('My Table'),('My Table'[Percentage])>=EARLIER('My Table'[Percentage])))

where 'Percentage' is the result of the measure in Column C, but 'EARLIER' does not work with measures.

GilbertQ
Super User
Super User

hi @kcdistiller

 

In terms of your data, does it have any dates associated with it?

 

If you have got a date, then you can easily create an interim calculated measure which will be the previous dates value.

NOTE: You will need a date table and create a relationship between the tables for this to work.

 

The example below is getting the values for the Previous Day.

 

Previous Row Data = 
CALCULATE (
    [Actuals],
        PARALLELPERIOD ( 'Date'[Calendar Date], -1, DAY ),
    )

And then your running total could be [Column D] + [Previous Row Data]





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Most solutions that I've found use dates, but there are no dates associated with my data.

Anonymous
Not applicable

Hi @kcdistiller

 

Can you post sample data on oneDrive or Drop box to arrive ata solution.

 

Also post the formula you have used for measure ColumnC

 

 

Cheers

 

CheenuSing

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.