Forum Discussion

RM117's avatar
RM117
Regular Visitor
2 years ago
Solved

Cumlative Measures

Good day all. I have a simple Budget table;

 

Project;     Fiscal Year      Budget

10x               2024           $1200

15x               2024           $1440

20x               2024           $1560

 

I also have a Calendar table. (Fiscal Year runs Apr 1 to Mar 31)

 

I was able to Break the Budget out per month with the Measure;

Budget Allocation =
      CALCULATE(   
      SELECTEDVALUE
                  (Budgets[Budget])/12,
                 'Actuals'
                  )
 
Now what I want to do is a cumulative total of the Budget Allocation. It would look like this in a table;
Month Year   Budget Allocation   Cumulative
April 2023          $100                     $100
May 2023           $100                     $200
Jun 2023             $100                     $300
July 2023            $100                     $400
 
Is it possible to use the Budget Allocation Measure within a new measure to get the Cumulative Measure?
 
Thanks in advance!
Kevin
 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi RM117 

     

    Please try this:

    First of all, I create a set of sample data:

    Then add a measure for reference:

    reference = SELECTEDVALUE('Table'[value])

    Then create a new measure:

    MEASURE 2=
    VAR _currentDate =
        MAX ( 'Table'[Month year] )
    VAR _previousDate =
        CALCULATE (
            MAX ( 'Table'[Month year] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Month year] < _currentDate )
        )
    VAR _newtavle =
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            'Table'[Month year],
            "_month year", SELECTEDVALUE ( 'Table'[Month year] ),
            "_reference", [reference]
        )
    RETURN
        SUMX ( FILTER ( _newtavle, [_month year] <= _currentDate ), [_reference] )

    The result is as follow:

     

    If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards

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

  • Hi,

    Split the original table into 36 rows (one for each month) - this can be done by simply merging a list of numbers from 1 to 12 with your table.  Create a column called budget per month.  Thereafter this measure will work

    B = sum(Data[Budget per month])

    Budget YTD = calculate([B],datesytd(calendar[date],"31/3"))

    Hope this helps.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi RM117 

     

    Please try this:

    First of all, I create a set of sample data:

    Then add a measure for reference:

    reference = SELECTEDVALUE('Table'[value])

    Then create a new measure:

    MEASURE 2=
    VAR _currentDate =
        MAX ( 'Table'[Month year] )
    VAR _previousDate =
        CALCULATE (
            MAX ( 'Table'[Month year] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Month year] < _currentDate )
        )
    VAR _newtavle =
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            'Table'[Month year],
            "_month year", SELECTEDVALUE ( 'Table'[Month year] ),
            "_reference", [reference]
        )
    RETURN
        SUMX ( FILTER ( _newtavle, [_month year] <= _currentDate ), [_reference] )

    The result is as follow:

     

    If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards

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

  • Hi,

    Split the original table into 36 rows (one for each month) - this can be done by simply merging a list of numbers from 1 to 12 with your table.  Create a column called budget per month.  Thereafter this measure will work

    B = sum(Data[Budget per month])

    Budget YTD = calculate([B],datesytd(calendar[date],"31/3"))

    Hope this helps.