Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am getting this error when I try to create a column in Power BI:
Function 'SWITCH' does not support comparing values of type True/False with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.
How do I fix this?
Here is the DAX for the column I am creating:
Status = SWITCH([G1TDTE] = "Null", "Plan", AND([G1DDTE] = "Null", [G1CDTE] = "Null"), "Undone Wip", [G1CDTE] = "Null", "Done Wip", "Finished")
The columns have the type text because I replaced values in query editor from 0 to "Null".
Solved! Go to Solution.
is this a colunm or a measure
if measure then you must use a max of the colunm values that you are comparing
Status = SWITCH ( TRUE(), MAX([G1TDTE]) = "Null", "Plan", AND ( max([G1DDTE]) = "Null", max([G1CDTE]) = "Null" ), "Undone Wip", max([G1CDTE]) = "Null", "Done Wip", "Finished" )
for colunm no max need use the col ref as is
Status_COL = SWITCH ( TRUE(), [G1TDTE] = "Null", "Plan", AND ([G1DDTE] = "Null", [G1CDTE] = "Null" ), "Undone Wip", [G1CDTE] = "Null", "Done Wip", "Finished" )
this only works if you have replaced you colunm with text colunms
Proud to be a Super User!
is this a colunm or a measure
if measure then you must use a max of the colunm values that you are comparing
Status = SWITCH ( TRUE(), MAX([G1TDTE]) = "Null", "Plan", AND ( max([G1DDTE]) = "Null", max([G1CDTE]) = "Null" ), "Undone Wip", max([G1CDTE]) = "Null", "Done Wip", "Finished" )
for colunm no max need use the col ref as is
Status_COL = SWITCH ( TRUE(), [G1TDTE] = "Null", "Plan", AND ([G1DDTE] = "Null", [G1CDTE] = "Null" ), "Undone Wip", [G1CDTE] = "Null", "Done Wip", "Finished" )
this only works if you have replaced you colunm with text colunms
Proud to be a Super User!
Hello @cchp07
I think it is just the first part of the SWITCH that is giving you trouble. If we change it like so it should work.
Status = SWITCH ( TRUE (), [G1TDTE] = "Null", "Plan", AND ( [G1DDTE] = "Null", [G1CDTE] = "Null" ), "Undone Wip", [G1CDTE] = "Null", "Done Wip", "Finished" )
Can you share a sample of the data in a format that can be copied (not a screen shot) or the .pbix file itself?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |