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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Clikojo
Regular Visitor

Function 'SWITCH' does not support comparing values of type Text with values of type True/False

Hello all, I am building a funnel chart. I am trying to have an overall/generic showing when there is no slicer selection and poduct specific categorys when there is a selection.

 

Here is my DAX:

 

DynamicStateGroup =
IF (
    ISFILTERED('ProductTable'[Product]),  -- Check if something is selected in the slicer
    'stg_product_onboarding'[updated_state],  -- If something is selected, return the original state
    SWITCH(
        'stg_product_onboarding'[updated_state],  -- When no slicer selection, group states
        "Onboarding Success", "Onboarding Success",
        'stg_product_onboarding'[updated_state] IN {"contract_1, "contract_2"}, "Sign Contracts",
        'stg_product_onboarding'[updated_state]
    )
)
 
However, I keep recieving this error
Function 'SWITCH' does not support comparing values of type Text with values of type True/False. Consider using the VALUE or FORMAT function to convert one of the values.

Thank you in advance!
1 ACCEPTED SOLUTION
Bibiano_Geraldo
Super User
Super User

Hi @Clikojo ,

It looks like the issue is with the way the SWITCH function is being used. The error occurs because SWITCH is trying to compare a text value with a boolean value. To fix this, you can use the SWITCH(TRUE(), ...) pattern, which allows for more flexible comparisons.

Here’s how you can modify your DAX formula:

DynamicStateGroup =
IF (
    ISFILTERED('ProductTable'[Product]),  -- Check if something is selected in the slicer
    'stg_product_onboarding'[updated_state],  -- If something is selected, return the original state
    SWITCH(
        TRUE(),
        'stg_product_onboarding'[updated_state] = "Onboarding Success", "Onboarding Success",
        'stg_product_onboarding'[updated_state] IN {"contract_1", "contract_2"}, "Sign Contracts",
        'stg_product_onboarding'[updated_state]
    )
)

 

Give this a try and let me know if it works for your funnel chart! If yes, please consider to accept as solution and give a Kudo. 

 

You can lear more about SWITCH function here 

 

Thank you.

View solution in original post

10 REPLIES 10
Bibiano_Geraldo
Super User
Super User

Hi @Clikojo ,

It looks like the issue is with the way the SWITCH function is being used. The error occurs because SWITCH is trying to compare a text value with a boolean value. To fix this, you can use the SWITCH(TRUE(), ...) pattern, which allows for more flexible comparisons.

Here’s how you can modify your DAX formula:

DynamicStateGroup =
IF (
    ISFILTERED('ProductTable'[Product]),  -- Check if something is selected in the slicer
    'stg_product_onboarding'[updated_state],  -- If something is selected, return the original state
    SWITCH(
        TRUE(),
        'stg_product_onboarding'[updated_state] = "Onboarding Success", "Onboarding Success",
        'stg_product_onboarding'[updated_state] IN {"contract_1", "contract_2"}, "Sign Contracts",
        'stg_product_onboarding'[updated_state]
    )
)

 

Give this a try and let me know if it works for your funnel chart! If yes, please consider to accept as solution and give a Kudo. 

 

You can lear more about SWITCH function here 

 

Thank you.

@Bibiano_Geraldo Thank you for your help. The issue I am still having is that the count changes when a selection is made but the funnel visual does not. With no slicer selection it shows the grouped categorys and with a selection the same thing but just with the correct count. I am entering this DAX as a new column within my table. This is the correct approach right?

Hi @Clikojo ,
To achieve dynamic behavior based on slicer selection, you should use a measure instead of a calculated column. Measures recalculate dynamically based on the filters and slicers applied in your report.

Here's revised DAX measure:

DynamicStateGroupMeasure =
IF (
    ISFILTERED('ProductTable'[Product]),  -- Check if something is selected in the slicer
    MAX('stg_product_onboarding'[updated_state]),  -- If something is selected, return the original state
    SWITCH(
        TRUE(),
        MAX('stg_product_onboarding'[updated_state]) = "Onboarding Success", "Onboarding Success",
        MAX('stg_product_onboarding'[updated_state]) IN {"contract_1", "contract_2"}, "Sign Contracts",
        MAX('stg_product_onboarding'[updated_state])
    )
)


Now you can use this measure in the funnel chart as your dynamic state field.

I hope this helps! 🎯
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
👍 Give it a kudo to show your appreciation!

Greg_Deckler
Super User
Super User

@Clikojo You need to use the SWITCH( TRUE(), ... ) version like this:

IF (
    ISFILTERED('ProductTable'[Product]),  -- Check if something is selected in the slicer
    'stg_product_onboarding'[updated_state],  -- If something is selected, return the original state
    SWITCH( TRUE(), 
        'stg_product_onboarding'[updated_state] IN {"contract_1, "contract_2"}, "Sign Contracts",
        'stg_product_onboarding'[updated_state]
    )
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks @Greg_Deckler, that seemed to resolve my error however, my funnel chart is not behaving as expected. These grouped categorys remain regardless if I have a selection on my slicer or not. Are you able to give some pointers as this might be happening please?

@Clikojo are there different tables you have used to built the funnel data, if so than it might be the relationship problem.

@SenPower I am using the same table 'stg_product_onboarding' for both the slicer and funnel. I use producttype for the slicer and trying to use dynamicstategroup in category for funnel visual

 

@Clikojo Can you modify your measure with this 
DynamicStateGroup =
IF (
HASONEVALUE('ProductTable'[Product]),
VALUES('stg_product_onboarding'[updated_state]),
SWITCH(
TRUE(),
'stg_product_onboarding'[updated_state] = "Onboarding Success", "Onboarding Success",
'stg_product_onboarding'[updated_state] IN {"contract_1", "contract_2"}, "Sign Contracts",
'stg_product_onboarding'[updated_state]
)
)

@SenPower Thank you for your help. The issue I am still having is that the count changes when a selection is made but the funnel visual does not. With no slicer selection it shows the grouped categorys and with a selection the same thing but just with the correct count. I am entering this DAX as a new column within my table. This is the correct approach right?

Ahhh, i undersrtand now, it seems like you have created a calculated column rather than a measure. Please create a measure not the column using the below DAX and is the table you are using as STG_Product_Onboarding check and see if that table depends on other tables if so than check the relationships of the table. 

But test it with the below DAX as a mesure not the calculated column. 
DynamicStateGroup =
IF (
ISFILTERED('ProductTable'[Product]), 
SELECTEDVALUE('stg_product_onboarding'[updated_state]), 
SWITCH(
TRUE(),
'stg_product_onboarding'[updated_state] = "Onboarding Success", "Onboarding Success",
'stg_product_onboarding'[updated_state] IN {"contract_1", "contract_2"}, "Sign Contracts",
'stg_product_onboarding'[updated_state] 
)
)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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