Forum Discussion
alejandroezp
Helper I
1 year agoUsing negation condition in switch function
Good morning, I am trying to use a negative condition in a switch function. My idea is to assign a label to all the rows where appears a string. I am using something like this example: NOT(CONT...
- 1 year ago
Hi alejandroezp
You can try CONTAINSSTRING( ) that returns TRUE/FALSE directly in your SWITCH function.
SWITCH( TRUE(), CONTAINSSTRING('Facturas'[Comentario], "gratis"), "Free", CONTAINSSTRING('Facturas'[Comentario], "oferta"), "Discount", -- Add more as needed TRUE, "Other" )
Cookistador
Super User
1 year agoHi alejandroezp
Normally, switch(true) should help you to achieve that
SWITCH(TRUE(),
CONTAINSSTRING('Facturas','Facturas'[Comentario],"gratis"), "gratis_label",
[Your Next Condition], "label_for_next_condition", // This will be evaluated if 'gratis' was NOT found
[Another Condition], "another_label",
...
"Default Label"
)
If it is not working, do not hesistate to share a dummy sample of what you are trying to achieve