Functions question: Switch() with else condition and If () with strings | Community
Skip to main content
gardensurfer
Level 3
August 27, 2024
Solved

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

  • August 27, 2024
  • 1 reply
  • 867 views

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: 

 

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: 

 

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

 

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

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Lawson02

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

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 &&, ||.

 

1 reply

Lawson02
Lawson02Accepted solution
Level 6
August 27, 2024

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

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 &&, ||.

 

gardensurfer
Level 3
August 29, 2024

Thank you!

Lawson02
Level 6
August 29, 2024

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!