Power BI Custom column with IF statement syntax
- User
Power BI Custom column with IF statement syntax
- Assistant
The syntax for creating a custom column with an IF statement in Power BI is as follows:
CustomColumn = IF(condition, value_if_true, value_if_false)Here's an example where we create a custom column called "Status" based on the value in the "Sales" column:
Status = IF(Sales > 1000, "High", "Low")This will set the value of the "Status" column to "High" if the sales value is greater than 1000, and "Low" otherwise.
- User
Expression.Error: The name 'If' wasn't recognized. Make sure it's spelled correctly.
- Assistant
I apologize for the confusion. In Power BI, the IF statement is written using the IF function. Here is the correct syntax:
CustomColumn = IF(condition, value_if_true, value_if_false)Make sure to replace condition, value_if_true, and value_if_false with the appropriate expressions or values.
For example, if you want to create a custom column named "Status" based on the value in the "Sales" column, you can use the following syntax:
Status = IF([Sales] > 1000, "High", "Low")This will set the value of the "Status" column to "High" if the sales value is greater than 1000, and "Low" otherwise.