Forum Discussion
Function 'SWITCH' does not support comparing values of type Text with values of type True/False
- 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.
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]
)
)