Expand my Community achievements bar.

Join us LIVE in San Francisco on November 14th for Experience Makers The Skill Exchange. Don't miss out on this free learning event!
SOLVED

Functions question: Switch() with else condition and If () with strings

Avatar

Level 3

I haven't had luck finding documentation on a couple of basic things. Examples provided on this site don't seem to address my specific use cases:

 

1) For a Switch() statement, where do I put the Else condition? I'd like the variable value to default to "n/a" if none of the cases are true in the below example: 

gardensurfer_0-1724778611134.png

 

2) For an If() statement, what's the syntax when testing equality with strings? In the below example, I don't use quotation marks because I didn't need them in the Switch() statement, but I notice that Fusion inserts  "+" and a quotation marks when I preview the statement before running just the one module.

 

The intent is that the variable value should be set to "Flow" only if both conditions (assayMethod=Biomarker and assayPurpose=Flow Cytometry) are met, and yet when running the module, I always get a variable value of Flow, regardless of inputs: 

gardensurfer_1-1724778709634.png 

>>> this is what it looks like in the "Run this module only" preview >>> 

gardensurfer_3-1724778812900.png

 

Could someone please advise on ways to make this work? Thank you. 

 

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hover over the function and look at the last example for the switch statement. You would put the N/A like: Biomarker;NA)

Lawson02_0-1724783619335.png

For your second question use a logical AND. if( assayPurpose = Biomarker AND assayPurpose = Flow Cytometry; Do stuff; Else). You don't need quotes when hardcoding strings but you do need to use the built in operators like the equals sign and the logical AND and OR instead of &&, ||.

Lawson02_1-1724783710333.png

 

View solution in original post

3 Replies

Avatar

Correct answer by
Level 5

Hover over the function and look at the last example for the switch statement. You would put the N/A like: Biomarker;NA)

Lawson02_0-1724783619335.png

For your second question use a logical AND. if( assayPurpose = Biomarker AND assayPurpose = Flow Cytometry; Do stuff; Else). You don't need quotes when hardcoding strings but you do need to use the built in operators like the equals sign and the logical AND and OR instead of &&, ||.

Lawson02_1-1724783710333.png

 

Avatar

Level 5

One thing that I forgot to mention was that Fusion put the "+" symbol there because it was trying to concatenate the strings together. Glad I was able to help!