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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
alejandroezp
Helper I
Helper I

Using 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(CONTAINS('Facturas','Facturas'[Comentario],"gratis")), "papo pepo",

 

The problem comes when this string assigns the result papo pepo when the condition is true and when it´s false.

How can i change the string to make the false results go to the next string of the function?

 

Cheers

1 ACCEPTED SOLUTION
MasonMA
Community Champion
Community Champion

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"
)

 

View solution in original post

5 REPLIES 5
v-saisrao-msft
Community Support
Community Support

Hi @alejandroezp,

Checking in to see if your issue has been resolved. let us know if you still need any assistance.

 

Thak you.

Good morning,

 

Sorry for delay, i was testing the solutions. At the end, the solution added by @MasonMA worked and it has solved my problem.

 

Thank you for the support

Cheers

v-saisrao-msft
Community Support
Community Support

Hi @alejandroezp,

Have you had a chance to review the solution we shared by @MasonMA @Cookistador. If the issue persists, feel free to reply so we can help further.

 

Thank you.

MasonMA
Community Champion
Community Champion

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
Super User

Hi @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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.