1
votes

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".

1

1 Answers

1
votes

A DAX measure can only return a single data type, not a string sometimes and a boolean sometimes. You can use the FORMAT function to turn a boolean into text:

Status =
SWITCH (
    [G1TDTE] = "Null",
    "Plan", FORMAT ( AND ( [G1DDTE] = "Null", [G1CDTE] = "Null" ), "True/False" ),
    "Undone Wip", [G1CDTE] = "Null",
    "Done Wip", "Finished"
)