Forum Discussion

Thigs's avatar
Thigs
Helper IV
1 year ago
Solved

Projection based on numeric parameters

Hi all!

I've been charged with creating a flexible business case tool, where the business users can input some items, get a cost, use a growth rate, and see how much it would cost year over year. 

 

I have the formula to get the total original cost, which I have called [Total Year 1 Costs]. I also have a numeric parameter that allows the user to select a growth rate (between 0.01 - 0.5) for the annual growth rate. I'm trying to allow them to also select the start year for the project ("Go Live Year"). The individual variables are working, but my switch formula is not. Any assistance is greatly appreciated!

 

Growing the Cost =
VAR Growth = (1+SELECTEDVALUE('Annual Growth Rate'[Annual Growth Rate]))
VAR BaseYear = [Total Year 1 Costs]
VAR Year1 = [Total Year 1 Costs]*Growth
VAR Year2 = Year1*Growth
VAR Year3 = Year2*Growth
VAR Year4 = Year3*Growth
VAR Year5 = Year4*Growth
VAR Year6 = Year5*Growth
VAR Year7 = Year6*Growth
VAR Year8 = Year7*Growth
VAR Year9 = Year8*Growth
VAR Year10 = Year9*Growth
VAR Year11 = Year10*Growth

RETURN
SWITCH(TRUE(),
MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year]), BaseYear,
MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+1, Year1,
MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+2, Year2,
MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+3, Year3,
MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+4, Year4,
MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+5, Year5


)
  • Hi Thigs ,

    To get more accurate projections, I’d suggest using a dynamic DAX calculation that responds to your input parameter. You can use something like SWITCH() or IF() in your measure to handle different values of the parameter.

    For example:

    Projected Value =
    SWITCH(
    TRUE(),
    [Parameter] = 1, [Value] * 1.1,
    [Parameter] = 2, [Value] * 1.2,
    [Parameter] = 3, [Value] * 1.3,
    [Value]
    )


    This way, the projections will automatically adjust depending on the input selected. It’s a flexible method and easy to maintain if you plan to add more conditions later. Also, just a quick tip if you're working with a large dataset, try to avoid using calculated columns unless necessary. Measures are generally more performance-friendly in such cases.
    Please feel free to come back if you have any queries.

    Thank you.

     

17 Replies

    • Thigs's avatar
      Thigs
      Helper IV

      No data is appearing within the graph. I am using a line chart, using Years as my X-axis (not "Go Live" year, but a year table that has one column, Years, from 2025 - 2100). I then pull the measure into the Y axis and nothing occurs. 

      • FBergamaschi's avatar
        FBergamaschi
        Super User

        I need to see columns grouped in rows amd columns section of the visual, the selection on slicers, need to see the data model

         

        Without contexts and Data model I cannot understand the issue

  • I agree, the problem must be here

     

    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year]), BaseYear,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+1Year1,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+2Year2,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+3Year3,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+4Year4,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year])+5Year5
     
    I assume the SELECTEDVALUE part is returning a blank as it finds more values, please turn it into
     
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year], -1), BaseYear,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year], -1)+1Year1,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year], -1)+2Year2,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year], -1)+3Year3,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year], -1)+4Year4,
    MAX(Years[Years]) = SELECTEDVALUE('Go Live Year'[Go Live Year], -1)+5Year5
     
    and try again, I expect some values now. But please turn the graph into a table, I want to see nrs
     
    To understand why SELECTEDVALUE does not find a single value, in case my intuition is correct, I need to see the tables and the model
     

    If this helped, please consider giving kudos and mark as a solution

    me in replies or I'll lose your thread

    Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

    Consider voting this Power BI idea

    Francesco Bergamaschi

    MBA, M.Eng, M.Econ, Professor of BI

    • Thigs's avatar
      Thigs
      Helper IV

      Hi! Thanks for the assistance, unfortunately that's still not working. I tried the table - it is blank. 

    • Thigs's avatar
      Thigs
      Helper IV

      So, I tried changing the formula to see if we can isolate what is going wrong. It's something with the Year = Go Live Year, because if I just tell it to use Year = 2025, etc, it is working. 

  • v-tejrama's avatar
    v-tejrama
    Community Support

    Hi Thigs ,

     

    Please follow these steps to achieve the desired outcome:

     

    1. Create a Parameter Table (Disconnected Table)

     

    ProjectionParams =
    DATATABLE(
        "Parameter", STRING,
        "Value", DOUBLE,
        {
            {"StartValue", 1000},
            {"GrowthRate", 0.10},
            {"DeclineRate", 0.05},
            {"GrowthMonths", 5},
            {"DeclineMonths", 3},
            {"TotalMonths", 12}
        }
    )

    2. Build a Calendar Table with a Month Index
    MonthIndex =
    ADDCOLUMNS(
        CALENDAR(DATE(2025, 1, 1), DATE(2025, 12, 31)),
        "MonthNum", DATEDIFF(DATE(2025, 1, 1), [Date], MONTH) + 1
    )
    This will generate 12 months, with the MonthNum column starting at 1.

     

    3. Define a Measure for Projected Value Calculation
    ProjectedValue =
    VAR StartValue = CALCULATE(MAX(ProjectionParams[Value]), ProjectionParams[Parameter] = "StartValue")
    VAR GrowthRate = CALCULATE(MAX(ProjectionParams[Value]), ProjectionParams[Parameter] = "GrowthRate")
    VAR DeclineRate = CALCULATE(MAX(ProjectionParams[Value]), ProjectionParams[Parameter] = "DeclineRate")
    VAR GrowthMonths = CALCULATE(MAX(ProjectionParams[Value]), ProjectionParams[Parameter] = "GrowthMonths")
    VAR DeclineMonths = CALCULATE(MAX(ProjectionParams[Value]), ProjectionParams[Parameter] = "DeclineMonths")
    VAR TotalMonths = CALCULATE(MAX(ProjectionParams[Value]), ProjectionParams[Parameter] = "TotalMonths")
    VAR MonthNum = SELECTEDVALUE('MonthIndex'[MonthNum])
    VAR Result =
        SWITCH(
            TRUE(),
            MonthNum = 1, StartValue,
            MonthNum <= GrowthMonths + 1, StartValue * POWER(1 + GrowthRate, MonthNum - 1),
            MonthNum <= GrowthMonths + DeclineMonths + 1,
                VAR GrowthEndValue = StartValue * POWER(1 + GrowthRate, GrowthMonths)
                VAR DeclineStep = MonthNum - GrowthMonths - 1
                RETURN GrowthEndValue * POWER(1 - DeclineRate, DeclineStep),
            BLANK()
        )
    RETURN Result

     

    4. Visualize the Results
    Create a line chart or table with the following:
     X-Axis: MonthIndex[Date]
     Y-Axis/Values: ProjectedValue (the measure above)
    This visualization will illustrate the projected curve based on the growth and decline parameters set.

    I’ve attached the .pbix file and screenshots for your reference.

     

     

    Best Regards,
    Tejaswi.
    Community Support

    • Thigs's avatar
      Thigs
      Helper IV

      But this won't work with my existing formula to find the cost, correct? I don't see the current cost anywhere in there. That formula has many pieces, so I need to be able to reference that measure. 

      • v-tejrama's avatar
        v-tejrama
        Community Support

        Hi Thigs ,

         

        You’re absolutely right the example I provided uses a static StartValue from the parameter table and doesn’t reference your [Total Year 1 Costs] formula.

        To incorporate your measure, simply update the measure by replacing this line:

        VAR StartValue = CALCULATE(MAX(ProjectionParams[Value]), ProjectionParams[Parameter] = "StartValue")

        with:

        VAR StartValue = [Total Year 1 Costs]

         

        This change ensures the projection logic is applied directly to your calculated cost. Make sure your [Total Year 1 Costs] measure returns accurate, context-dependent results, especially when filters like category, year, or month are involved. That way, your projections will stay precise.

         

        Best regards,
        Tejaswi.
        Community Support Team