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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic Calculation (Need Help!!)

Is this possible to be done in powerbi? 

 

Example in forecasting:

 

In 2020 I have 50,  dashboard filter 5% to the number for the following forecast years. 

 

Start of forcasting and the expected result: 

in

2020: 50
2021 : 50-(50*0.05) = 48

2022: 48 - (48*0.05) = 46

2023: 46 - (46*0.05) = 44

.

.

2025

 

 

2 ACCEPTED SOLUTIONS
v-yalanwu-msft
Community Support
Community Support

Hi @Anonymous  ,


According to your description, you could create what-if parameter, then create measure (based on the what-if parameter); the following formula to create a measure :
Step 1: Add what-if parameter(Percentage)
what if parameter.jpg
Step2: Add measure(Value)

Value =
VAR _a =
    MAX ( 'Table'[Year] ) - 2020
RETURN
    CALCULATE (
        MAX ( 'Table'[Sales] ) * ( 1 - [Percentage Value] ) ^ _a,
        ALL ( 'Table' )
    )

The final output is shown below:

dynamic calculate.pngdynamic calculate2.png

Best Regards,
Yalan Wu
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

You could modify the measure by the following:

value =
VAR _a =
    MAX ( 'Table'[Year] ) - 2020
RETURN
    CALCULATE (
        MAX ( 'Table'[Sales] ) * ( 1 - [Percentage Value] + [scenario Value] ) ^ _a,
        ALL ( 'Table' )
    )

The final output is shown below:

v-yalanwu-msft_0-1618914074453.png

Best Regards,
Yalan Wu
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

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi @Anonymous  ,


According to your description, you could create what-if parameter, then create measure (based on the what-if parameter); the following formula to create a measure :
Step 1: Add what-if parameter(Percentage)
what if parameter.jpg
Step2: Add measure(Value)

Value =
VAR _a =
    MAX ( 'Table'[Year] ) - 2020
RETURN
    CALCULATE (
        MAX ( 'Table'[Sales] ) * ( 1 - [Percentage Value] ) ^ _a,
        ALL ( 'Table' )
    )

The final output is shown below:

dynamic calculate.pngdynamic calculate2.png

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

Anonymous
Not applicable

Hi @v-yalanwu-msft, thanks for your solution!!

 

what if the scenario is like - i have 2 what-if parameters, attrition 5% and recruitment 3%

2020:52
2021: 52- (52*5%)+(52*3%) = 51
2022: 51-(51*5%)+(51*3%) = N
20233:N-(N*5%)+(51*3%)=N
.
.

You could modify the measure by the following:

value =
VAR _a =
    MAX ( 'Table'[Year] ) - 2020
RETURN
    CALCULATE (
        MAX ( 'Table'[Sales] ) * ( 1 - [Percentage Value] + [scenario Value] ) ^ _a,
        ALL ( 'Table' )
    )

The final output is shown below:

v-yalanwu-msft_0-1618914074453.png

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

 

Anonymous
Not applicable

Hi @CNENFRNL, thanks for your input. 

My Question - if the 5% is based on the what-if parameter, can it still be populate using the script you share? 

CNENFRNL
Community Champion
Community Champion

@Anonymous , simply an algbra question,

f(n)=f(n-1)*(1-0.05)=f(n-2)*(1-0.05)^2= ... =f(0)*0.95^n
let
    Source = Table.FromList({2020..2025}, Splitter.SplitByNothing(), {"Yr"}),
    Yr2020 = 50,
    #"Added Custom" = Table.AddColumn(Source, "Forecast_PQ", each Number.RoundUp(Yr2020 * Number.Power(.95, [Yr]-2020)))
in
    #"Added Custom"

Screenshot 2021-04-13 193820.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.