cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rubal Frequent Visitor
Frequent Visitor

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)]))
 
 
Variant data type error.jpg
12 REPLIES 12

Re: DAX IF Formula error

Hi @Rubal 

 

change the data type from Text to Wole Number.

The calculation columns you are doing in this formula.

 

ss.PNG

 

 

Rubal Frequent Visitor
Frequent Visitor

Re: DAX IF Formula error

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 Established Member
Established Member

Re: DAX IF Formula error

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.

Arjunarao Regular Visitor
Regular Visitor

Re: DAX IF Formula error

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 Frequent Visitor
Frequent Visitor

Re: DAX IF Formula error

Hi Arjun,

 

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

Arjunarao Regular Visitor
Regular Visitor

Re: DAX IF Formula error

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)] )
)
Rubal Frequent Visitor
Frequent Visitor

Re: DAX IF Formula error

Hi Arjun,

 

Please excuse my ignorance. but where is the difference between the codes? seems exactly the same as mine but formatting. appreciate your help.

Arjunarao Regular Visitor
Regular Visitor

Re: DAX IF Formula error

Hi @Rubal
You can use this link for DAX format.
https://www.daxformatter.com/
Rubal Frequent Visitor
Frequent Visitor

Re: DAX IF Formula error

Hi Arjun,

 

Changing the formatting didn't solve the error 😞

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 157 members 1,560 guests
Please welcome our newest community members: