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
thekimberlytan
Frequent Visitor

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 @thekimberlytan  ,


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 @thekimberlytan  ,


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.

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.

 

thekimberlytan
Frequent Visitor

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

@thekimberlytan , 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
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.