Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
m1kias
New Member

I need help converting a simple Excel formula to DAX

I am currently struggling converting an excel formula to DAX format. The formula is:

 

 

=IFERROR(IF([Variance]/ABS([2021 Amount])<-10000000,-1,IF([Variance]/ABS([2021 Amount])>10000000,1,[Variance]/ABS([2021 Amount]))),0)

 

Variance and 2021 Amount are both the collumns I am calculating the data from. I am adding it as a measure in a pivot table because when I filter the pivot table I want the percentage of varance be calculated on the grand total as well rather than a sum of the percentages. Which is useless when looking at percentages.

 

Many thanks.

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @m1kias,

Any update on this? Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
vapid128
Solution Specialist
Solution Specialist

In dax, the formula should be all same.

All you need to do is repleace A/B to DIVIDE(A,B) 

Thank you for your contribution vapid128. I replaced the formula with the following but unfortunately it did not work.

 

IFERROR(IF(DIVIDE([Variance],ABS([2021 Amount]))<-10000000,-1,IF(DIVIDE([Variance],ABS([2021 Amount]))>10000000,1,DIVIDE([Variance],ABS([2021 Amount])))),0)

 

It is giving me the following message. 

 

"A single value for column 'Variance' in table 'Range' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.'."

vapid128
Solution Specialist
Solution Specialist

I am sorry, I didn't see you want to add a measure.

 

Since [Variance] is a colnum, you need to tell dax, how it become a measure.

like Min/Max/Sum/Average.....

 

When you write "[Variance]/ABS([2021 Amount])<-10000000"

IF all in colnum or measure, it will be very clear to understand.

But if it is from colnum to measure, it is not that clear.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors