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
ayeoh
Employee
Employee

Need Dynamic Forecast Measure

URGENT DAX Question:

How do I modify this dax: Forecast = CALCULATE(SUM('Q3 Forecast'[Forecast]))
such that selected value if dimTime[Fiscal Quarter]=Q2, then CALCULATE(SUM('Q2 Forecast'[Forecast]),

otherwise if selected value of dimTime[Fiscal Quarter] = Q3 or Q4, then CALCULATE(SUM('Q3 Forecast'[Forecast])).

Thanks so much!

1 ACCEPTED SOLUTION
DataZoe
Employee
Employee

Hi @ayeoh ,

 

If it's only Q2 that has a different forecast, you might be able to try this simple solution:

 

SWITCH(
SELECTEDVALUE('dimTime'[Fiscal Quarter]),
"Q2", SUM('Q2 Forecast'[Forecast]),
SUM('Q3 Forecast'[Forecast])
)

 It could be an IF too, but I left it at SWITCH in case you wanted to check for BLANK() and have it return BLANK() if no quarter is selected.

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

8 REPLIES 8
DataZoe
Employee
Employee

Hi @ayeoh ,

 

If it's only Q2 that has a different forecast, you might be able to try this simple solution:

 

SWITCH(
SELECTEDVALUE('dimTime'[Fiscal Quarter]),
"Q2", SUM('Q2 Forecast'[Forecast]),
SUM('Q3 Forecast'[Forecast])
)

 It could be an IF too, but I left it at SWITCH in case you wanted to check for BLANK() and have it return BLANK() if no quarter is selected.

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Thanks @DataZoe That worked!

aj1973
Community Champion
Community Champion

Hi @ayeoh 

Try this

Forecast =
VAR _FiscalQurter = SELECTEDVALUE(dimTime[Fiscal Quarter])

VAR _F1 = CALCULATE(SUM('Q1 Forecast'[Forecast]))

VAR _F2 = CALCULATE(SUM('Q2 Forecast'[Forecast]))

VAR _F3_F4 = CALCULATE(SUM('Q3 Forecast'[Forecast]))

VAR Result = IF(_FiscalQurter = Q1, _F1 ,
                                    IF(_FiscalQurter = Q2,

                                                                       _F3_F4
                         ) )
RETURN

Result

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Thanks Amine. Can you pls take a look at the screenshot.

I need it so if Fiscal Quarter = Q2, then _F2, but if Fiscal Quarter = Q3 or Fiscal Quarter = Q4, then _F3_F4.

The 1st condition is clear to me (Q2).

But how can I modify the 2nd condition so that if Fiscal Quarter = Q3 or Q4, then _F3_F4.

If I want to use a SWITCH statement, how would that look like?
Thanks!

dax.png

aj1973
Community Champion
Community Champion

How about Q1, Return = Blank()? if so then

 

VAR Result = IF(_FiscalQurter = Q2, _F2 ,
                                    IF(OR(_FiscalQurter = Q3, _FiscalQurter = Q4)

                                                                       _F3_F4,

                                                                                Blank()
                         ) )

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Thanks again Amine. I don't need Q1 because there is not forecast for Q1 (Q1 is only budget so pulls from different table). So I modified the formula and there is new error 😞

dax.png

aj1973
Community Champion
Community Champion

aj1973_0-1705111432362.png

 

check out which one!

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Do you mean delete each ")" by trial and error until the error is resolved?

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.