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

cumulative loss over time

Hi,

 

I have two tables, one is a list of jobs with job numbers and job budget, a second table contioans job costs (amount, date)

 

I want to be able to see in a matrix when the job is loosing, e.g. budget-cumulative, I can get the cumulative but I cannot substract it from the budget

 

 

This is what I want to get to 

mpsAutomation_0-1682035268038.png

 

At the moment All I can see is the cumulative of cost amount but cannot substract tthe budget

mpsAutomation_1-1682035532571.png

 

Measure 2 =
VAR a = MIN ( 'calendar'[Date] )
VAR maxd = CALCULATE ( MAX ( 'MErged costs'[Date] ), ALL ( 'MErged costs' ) )
VAR jobN = SELECTEDVALUE( 'JobList'[Job No.] )

RETURN
    IF (
        a <= maxd,  
        CALCULATE (
            SUM ( 'MErged costs'[Cost] ),
            FILTER ( ALL ( 'calendar' ), 'calendar'[Date] <= a )
        )
    )
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @mpsAutomation 

According to your description, you want to substract the  cumulative  of budget.

If this , you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1682307217846.png

(2)We can create a measure like this:

Measure = 
VAR a = MIN ( 'calendar'[Date] )
VAR maxd = CALCULATE ( MAX ( 'MErged costs'[Date] ), ALL ( 'MErged costs' ) )
VAR jobN = SELECTEDVALUE( 'JobList'[Job No.] )
var _cost = CALCULATE (
            SUM ( 'MErged costs'[Cost] ),
            FILTER ( ALL ( 'calendar' ), 'calendar'[Date] <= a )
        )
var _budget = CALCULATE (
            SUM ('Budget Table'[Budget] ),
            FILTER ( ALL ( 'calendar' ), 'calendar'[Date] <= a )
        )
RETURN
    IF (
        a <= maxd,  
        _cost - _budget
    )

(3)Then we can put this measure on the visual and we can get the result like this:

vyueyunzhmsft_1-1682307267186.png

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

View solution in original post

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @mpsAutomation 

According to your description, you want to substract the  cumulative  of budget.

If this , you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1682307217846.png

(2)We can create a measure like this:

Measure = 
VAR a = MIN ( 'calendar'[Date] )
VAR maxd = CALCULATE ( MAX ( 'MErged costs'[Date] ), ALL ( 'MErged costs' ) )
VAR jobN = SELECTEDVALUE( 'JobList'[Job No.] )
var _cost = CALCULATE (
            SUM ( 'MErged costs'[Cost] ),
            FILTER ( ALL ( 'calendar' ), 'calendar'[Date] <= a )
        )
var _budget = CALCULATE (
            SUM ('Budget Table'[Budget] ),
            FILTER ( ALL ( 'calendar' ), 'calendar'[Date] <= a )
        )
RETURN
    IF (
        a <= maxd,  
        _cost - _budget
    )

(3)Then we can put this measure on the visual and we can get the result like this:

vyueyunzhmsft_1-1682307267186.png

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

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!

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.