Forum Discussion

Rubal's avatar
Rubal
Helper II
7 years ago

DAX IF Formula error

Hi,

 

I am getting the below errors on the If Formula. Can anyone please help on how to resolve it?

Thank you. 

 

 

Vol(Cases / Suom) = if (t_sales_aggregate[Actual or Forecast]="Forecast", (t_sales_aggregate[Volume (Cases)] && t_sales_aggregate[Volume (SUOM)])*AVERAGE(t_sales_aggregate[Forecast Growth]), (t_sales_aggregate[Volume (Cases)]&&t_sales_aggregate[Volume (SUOM)]))
 
 

12 Replies

  • adityavighne's avatar
    adityavighne
    Continued Contributor

    Hi Rubal 

     

    change the data type from Text to Wole Number.

    The calculation columns you are doing in this formula.

     

     

     

    • Rubal's avatar
      Rubal
      Helper II

      Hi Aditya,

       

      Thanks for your comments. As I am new to Power BI I am not sure how to do it. As it is a calculated column I do not see it in the query editor. How and where can I change the data type? Your help is highly appreciated.

       

      Thanks.

      • tarunsingla's avatar
        tarunsingla
        Solution Sage

        The error message indicates that the data type of the calculation for if true section is different than the data type for the if false section. Ensure that in an IF statement, the data type of the resulting expression is same for all cases.

  • Hi,

    To change the data type of a column from source is :

    Go to Edit Query

    Select the column

    Go to Transform tool bar > Data Type and change 

     

    • Rubal's avatar
      Rubal
      Helper II

      Hi Arjun,

       

      I don't even see the column into the query editor? Is this because it is a column measure?

      • Arjunarao's avatar
        Arjunarao
        Resolver I
        Yes.
        Specified columns in your expression.
        Vol(Cases / Suom) =
        IF (
        t_sales_aggregate[Actual or Forecast] = "Forecast",
        ( t_sales_aggregate[Volume (Cases)] && t_sales_aggregate[Volume (SUOM)] )
        * AVERAGE ( t_sales_aggregate[Forecast Growth] ),
        ( t_sales_aggregate[Volume (Cases)] && t_sales_aggregate[Volume (SUOM)] )
        )