Forum Discussion

Landcrab's avatar
Landcrab
Helper I
6 years ago
Solved

Cumulative total for WHATIF parameters

Hi there, Is it possible to calculate the cumulative amount for two WHATIF parameters?   I have a date table and I am able to calculate cumulative total for all my other amounts that have a date b...
  • Landcrab's avatar
    Landcrab
    6 years ago

    Hi Jay,

     

    Yes that's my conclusion as well, it cannot be done using just WHATIF parameters alone.

     

    My workaround has been to create a new table containing the MIN value for the two variables and a date column allowing it to be linked to date table.

     

    Then create two WHATIF paramters for the same variables with the desired range starting at the same MIN value from the column.

    Then created two new measures that link the column with the WHATIF parameters to increase the 'No of Docs' and/ or 'Amount' as per user input. This then enables me to create cumulative figure for them because they are now linked to the date table.


    New table 'Current Cost'

    Month Number NoOfDocs Amount
    1 100 10
    2 100 10
    3 100 10...etc

     

    WHATIF parameter 1
    NoOfDocs = GENERATESERIES(100, 5000, 100)

    WHATIF parameter 2
    Amount = GENERATESERIES(10, 15.5, 0.25)


    Work out the amount:

    Current Cost Total =

    VAR NumOfDocsToBeAdded =
    IF( [NoOfDocs] = 100, 0, [NumberOfDocumentsMetric Value] - 100 )

    // 'NumOfDocsToBeAdded' variable used to work out if WHATIF value has increased and if so work out by how much compared to MIN (100)


    VAR CurrentCostPerDocToBeAdded =
    IF( [Amount] = 10, 0, [CurrentCostMetric Value] - 10 )

    // 'CurrentCostPerDocToBeAdded' variable used to work out if WHATIF value has increased and if so work out by how much compared to MIN (10)


    RETURN
    CALCULATE(
    SUMX( 'Current Cost', ( 'Current Cost'[Amount] + CurrentCostPerDocToBeAdded ) * ( 'Current Cost'[NoOfDocs] + NumOfDocsToBeAdded ) ),
    CROSSFILTER( 'Current Cost'[Month Number], 'Calendar'[Begining Start Month Number], Both )
    )

     


    Cumulative Total:


    Cumulative Current Cost =
    CALCULATE(
    [Current Cost Total],
    FILTER( ALL( 'Calander' ),
    'Calendar'[Date] <= MAX( 'Calendar'[Date] ) )


    That worked for me.