Forum Discussion

Clikojo's avatar
Clikojo
Frequent Visitor
1 year ago
Solved

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: ...
  • Bibiano_Geraldo's avatar
    1 year ago

    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.