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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply

DAX - Switch Function with What if Scenarios

Hi! I am working on a report, which I am creating multiple what if scenarios. 

In that, I am creating 3 what if Scenario. 

 

1A - Whole Number

2B - Whole Number

2C - Fixed Decimal - Conversion Rate  - 2B & 2C are to be expected to work together.

 

jayasurya_prud_0-1675250542199.png

 

Now, If I slice 1A as 500 - The Result should show as 500

 

If I want to use the combo of 2B and 2C (2B = 500, 2C = 10%) it should overwrite the 1A result of 500 and show 50. 

 

For this I am using Switch Function, 
-------------------------------------------------------------------

SWITCH(
SELECTEDVALUE('1A'[1A]),'1A'[1A Value],
SELECTEDVALUE('2B'[2B]),'Measure'[2a_2b])
 
--------------------------------------------------------------------
The 'Measure'[2a_2b] = 
 
var x = SELECTEDVALUE('2A'[2A])

return x*'2B'[2B Value]
 
---------------------------------------------------------------------------
 
I am not getting the expected results. I think I miss somewhere in Expression in Swithc DAX
 
If I slice 1A - no reaction. 
 

If I slice 2A as 100, I am getting 100 as result. But the Expected result is 0 as the 2B is 0%. The 2B is not playing part in it.

Please help me for the solution.

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @jayasurya_prud ,

 

 

If I slice 2A as 100, I am getting 100 as result. But the Expected result is 0 as the 2B is 0%. The 2B is not playing part in it.

 

I couldn't find 2A in your screenshot and I think 2C should be in percentage data type and 2B should be in number type.

So I guess Measure''[2a_2b] ' may be 2C*2B.

Measure = 
IF(ISFILTERED('2B'[2B])||ISFILTERED('2C'[2C]),[2B Value] * [2C Value] ,[1A Value])+0

RicoZhou_0-1675328841439.png

RicoZhou_0-1675328958773.png

If this reply still couldn't help you solve your issue, please show me more details. You can share a sample file with me and show me a screenshot with the result you want.

 

Best Regards,
Rico Zhou

 

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.