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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
o59393
Post Prodigy
Post Prodigy

How to use switch with 2 logical conditions

Hi all

 

I am trying to use a switch with 2 logical conditions. Basically if the column "ES-RQ-225-Param" has a certain text and column "Result" is within the specied column "target", then return "in".

 

For example, the targets for the following parameters are:

 

ES-RQ-225ParámTargetLookup
Cloro Residual o Ausente / Chlorine, residual (mg/L) - 0.10.1<
BOD5 (mg/L) - 5050<
Aluminio / Aluminum (mg/L) - 1.51.5<

 

I am using the following formula

 

Column = 
SWITCH(
    TRUE(),
    'Append'[ES-RQ-225Parám]="Cloro Residual o Ausente / Chlorine, residual (mg/L) - 0.1" && 'Append'[Result] < 'Append'[Target],"In",
    'Append'[ES-RQ-225Parám]="BOD5 (mg/L) - 50" && 'Append'[Result] < 'Append'[Target],"In",
    'Append'[ES-RQ-225Parám]="Aluminio / Aluminum (mg/L) - 1.5" && 'Append'[Result] < 'Append'[Target],"In",
    "Out"
)
    

 

As seen, if '[ES-RQ-225Parám]="Cloro Residual o Ausente / Chlorine, residual (mg/L) - 0.1" and [Result] < 'Append'[Target], then I want to have an "In". 

 

In this case for "Cloro Residual o Ausente / Chlorine, residual (mg/L) - 0.1" the target is 0.1 as seen below.

 

However it's returning me an error:

 

sdsada21.JPG

 

How can I get it right?

 

Thanks!

 

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

HI @o59393 ,

 

'You need to convert the data type of 'Target Column' to Decimal Number. 

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

1 REPLY 1
harshnathani
Community Champion
Community Champion

HI @o59393 ,

 

'You need to convert the data type of 'Target Column' to Decimal Number. 

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.