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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
enedella
Frequent Visitor

Cumulative What if Parameter

I am trying to create a what if scenario and make the amounts cumulative over each year.

 

There is a slicer to choose what contract year the adjusted amount should start in and then a what-if parameter that has a slider to choose the adjusted $ amount. So for this example, the CY would be CY2 and the slider would have -$100.

 

My current formula to get the adjustment to start in the year that is selected from the slicer is:

 

 

 

Adj Amount cumulative =

 

 

 

IF(VALUES('GP Invoices SCENARIOS'[CY]) = "CY1",'$ Spend Cumulative'[$ Spend Cumulative Value],

 

IF(VALUES('GP Invoices SCENARIOS'[CY]) = "CY2",'$ Spend Cumulative'[$ Spend Cumulative Value],

 

IF(VALUES('GP Invoices SCENARIOS'[CY]) = "CY3",'$ Spend Cumulative'[$ Spend Cumulative Value],

 

IF(VALUES('GP Invoices SCENARIOS'[CY]) = "CY4",'$ Spend Cumulative'[$ Spend Cumulative Value],

 

IF(VALUES('GP Invoices SCENARIOS'[CY]) = "CY5",'$ Spend Cumulative'[$ Spend Cumulative Value],0)))))

 

 

 

This is the formula that I tried to use to make the adj amount cumulative:

 

 

 

 

 

Adj Amount Cumulative running total in Contract Year =

 

CALCULATE(

 

    [Adj Amount Cumulative],

 

    FILTER(

 

        ALLSELECTED('Dates'[Contract Year]),

 

        ISONORAFTER('Dates'[Contract Year], MAX('Dates'[Contract Year]), DESC)

 

    )

 

)

 

 

 

 

The $ Spend Cumulative comes from the slicer and has this formula:

 

 

 

$ Spend Cumulative Value = SELECTEDVALUE('$ Spend Cumulative'[Additional Amount Spent Cumulative])

 

 

 

This is what my table currently looks like:

 

 

                                                  Base spend after

              Base Spend        Adjusted Spend    Adjusted Amount

CY1         $200                   $200                                       $0

CY2        $500                    $400                                     -$100

CY3        $600                    $500                                      -$100

CY4        $800                    $700                                      -$100

Total      $2,100                 $1,800                                -$100                        

 

 

Here is what I would like the table to display.

 

                                                  Base spend after

              Base Spend        Adjusted Spend    Adjusted Amount

CY1         $200                   $200                                       $0

CY2        $500                    $400                                     -$100

CY3        $600                    $400                                      -$200

CY4        $800                    $500                                      -$300

Total      $2,100                   $1,500                                 -$600   

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @enedella ,

You can try to use following measure formula if it works for your scenario:

Measure =
VAR _select =
    SELECTEDVALUE ( 'GP Invoices SCENARIOS'[CY] )
VAR _date =
    CALCULATETABLE (
        MAX ( Dates[Date] ),
        FILTER ( ALL ( Dates ), [Contract Year] = _select )
    )
RETURN
    CALCULATE (
        SUM ( Table[Based Spend] ) - SUM ( Table[Adjusted Spend] ),
        FILTER ( ALLSELECTED ( Table ), Table[Date] <= _date )
    )

If above not help, please share some sample data for test.

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @enedella ,

You can try to use following measure formula if it works for your scenario:

Measure =
VAR _select =
    SELECTEDVALUE ( 'GP Invoices SCENARIOS'[CY] )
VAR _date =
    CALCULATETABLE (
        MAX ( Dates[Date] ),
        FILTER ( ALL ( Dates ), [Contract Year] = _select )
    )
RETURN
    CALCULATE (
        SUM ( Table[Based Spend] ) - SUM ( Table[Adjusted Spend] ),
        FILTER ( ALLSELECTED ( Table ), Table[Date] <= _date )
    )

If above not help, please share some sample data for test.

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you, I will try this. Will you please explain the measure? @v-shex-msft 

Hi @enedella ,

Sure, you can take a look at following formula logic if it helps.

Logic:

1. Use selectedvalue function to get selection from slicer and stored to variable.
2. Use selected CY value to find out correspond date range, then extract max date from that range and cache to variable.
3. Do cumulative calculation on date range (less than or equal to max date which I calculated above).

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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