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
pbiuser0000
Regular Visitor

Calculate % Previous Scenario

Hello all, 

 

I'm struggling on how to build my measure

 

Here's the context, I have one source as follows : 

 

ScenarioProductSales
Actual 2018X10
Actual 2018Y20
Actual 2019X20
Budget 2020X100
Budget 2020Y150
Forecast1 2020X200
Forecast1 2020Y250
Forecast2 2020X210
Forecast2 2020Y260
Actual 2020X100
Actual 2020Y200

 

I would like in a dynamic way when I select a scenario as filter calculate the variation between the scenario selected and the previous one.

 

FYI the order of the scenario is Budget -> Forecast1 -> Forecast2 -> Actual

E.g :

I select Actual 2020, my measure calculate the variation between Actual 2020 and Forecast2 2020.

I select Forecast2 2020, my measure calculate the variation between Forecast2 2020 and Forecast1 2020.

....

I select Budget 2020, my measure returns null as there's no previous scenario.

Same for Actual 2018 and Actual 2019

 

Thank you for your help.

 

 

 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @pbiuser0000 ,

 

It is recommended that you split Scenario column, which is helpful for DAX calculation.

Custom sort for the items in column Scenario in the query editor.Then create a column like below:

Column = 
var last_ = CALCULATE(FIRSTNONBLANK('Table'[Sales],1),FILTER(ALLEXCEPT('Table','Table'[Scenario.2],'Table'[Product]),EARLIER('Table'[Custom])='Table'[Custom]+1))
return IF(ISBLANK(last_),BLANK(),'Table'[Sales]-last_)

Vlianlmsft_0-1624255515222.png

 

 

Best Regards,
Liang
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

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Hi @pbiuser0000 ,

 

It is recommended that you split Scenario column, which is helpful for DAX calculation.

Custom sort for the items in column Scenario in the query editor.Then create a column like below:

Column = 
var last_ = CALCULATE(FIRSTNONBLANK('Table'[Sales],1),FILTER(ALLEXCEPT('Table','Table'[Scenario.2],'Table'[Product]),EARLIER('Table'[Custom])='Table'[Custom]+1))
return IF(ISBLANK(last_),BLANK(),'Table'[Sales]-last_)

Vlianlmsft_0-1624255515222.png

 

 

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

Dear Liang,

 

Thank you a lot for your help !

 

It works perfectly well.

 

Regards.

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.