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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Clikojo
Frequent 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
Community Champion
Community Champion

@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!:
DAX For Humans

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors