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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
PBrainNWH
Helper II
Helper II

Running Total of a Measure

I'm trying to get a running total of my Variance column. Variance is a measure of (Budget - Spend). Here is the Running Total measure I've created and the results. The weird thing is it starts the running total in the first month where there's no spend amount (January), otherwise it's just giving me the total of the Variance column until then.

 

VarRunning Total =
    VAR maxdate = MAX('Calendar (2)'[Date])
    VAR varAmt = 'PL&PIL&Budget Append'[Budget Amount]-'PL&PIL&Budget Append'[Spend Amount]
    RETURN
    CALCULATE(
        SUMX('PL&PIL&Budget Append','PL&PIL&Budget Append'[Variance]),
        'Calendar (2)'[Date] <= maxdate,
        ALL('Calendar (2)'[Date])
    )
 
PBrainNWH_0-1702358894604.png

 


 

 
1 ACCEPTED SOLUTION

I've tried replicating, and mine seems to work. Here is how mine is built, take a look and compare with yours for any "ah-ha's."

 

Sample Data:

CoreyP_0-1702364382390.png

Model:

CoreyP_1-1702364414180.png

Measures:

Budget = CALCULATE( SUM( 'P&L Sample'[LineAmount] ) , 'P&L Sample'[Status] = "Budget" )

Spend = CALCULATE( SUM( 'P&L Sample'[LineAmount] ) , 'P&L Sample'[Status] = "Spend" )

Variance_ = [Budget] - [Spend]

VAR Running Tot = 
VAR _maxdate = MAX( 'Date'[Date] )
VAR _logic =
SUMX( 
    FILTER( 
        ALL('Date') , 'Date'[Date] <= _maxdate ) , 
        [Variance_] 
)

RETURN
_logic

Output:

CoreyP_2-1702364575618.png

 

View solution in original post

9 REPLIES 9
CoreyP
Solution Sage
Solution Sage

Think you want this:

Cumulative = 
VAR _maxdate = MAX( 'Date'[Date] )
VAR _logic =
SUMX( 
    FILTER( 
        ALL('Date') , 'Date'[Date] <= _maxdate ) , 
        [Variance] 
)

RETURN
_logic

Here's what I entered:

VarRunning Total =
VAR _maxdate = MAX( 'Calendar (2)'[Date] )
VAR _logic =
SUMX(
    FILTER(
        ALL('Calendar (2)'[Date]) , 'Calendar (2)'[Date] <= _maxdate ) ,
        [Variance]
)

RETURN
_logic
 
The results are the same:


PBrainNWH_0-1702360347908.png

 

I have a feeling it's a problem with your date periods since you are using custom fiscal periods. 

Can you please share a sample of your data and a screenshot of your model?

Here is a sample of data from the main table:

PBrainNWH_0-1702361006270.png

 

Here is the portion of the model:

PBrainNWH_1-1702361254470.png

 

Both the Budget and Spend Amounts are measures constructed as such:

 
Budget Amount = CALCULATE(SUM('PL&PIL&Budget Append'[Line Amount]),FILTER('PL&PIL&Budget Append','PL&PIL&Budget Append'[Status]="Budget"))+0

And the FY24 Month column in your visual is coming from the Calendar (2) table, yes?

Yes.

 

PBrainNWH_0-1702363450300.png

 

I've tried replicating, and mine seems to work. Here is how mine is built, take a look and compare with yours for any "ah-ha's."

 

Sample Data:

CoreyP_0-1702364382390.png

Model:

CoreyP_1-1702364414180.png

Measures:

Budget = CALCULATE( SUM( 'P&L Sample'[LineAmount] ) , 'P&L Sample'[Status] = "Budget" )

Spend = CALCULATE( SUM( 'P&L Sample'[LineAmount] ) , 'P&L Sample'[Status] = "Spend" )

Variance_ = [Budget] - [Spend]

VAR Running Tot = 
VAR _maxdate = MAX( 'Date'[Date] )
VAR _logic =
SUMX( 
    FILTER( 
        ALL('Date') , 'Date'[Date] <= _maxdate ) , 
        [Variance_] 
)

RETURN
_logic

Output:

CoreyP_2-1702364575618.png

 

Still getting the same results. I'm perplexed. Closing thread for now. I'll take a look at a few things.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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