Skip to content
The Chat Archive
gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)

Power BI Custom column with IF statement syntax

  1. User

    Power BI Custom column with IF statement syntax

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

  3. User

    Expression.Error: The name 'If' wasn't recognized. Make sure it's spelled correctly.

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