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
harry843
New Member

DAX IF OR Statement

Hi All - I'm new to PowerBI and the community and could really use some help with a DAX IF statement which I am stuck on.

 

I have a simple table with two columns (SiteId and Att Rate) and wish to create a new measure. I want this measure to say:

 

'If SiteId equals 28 or 52, then return "0.1%", else return Att Rate"

 

I have tried this in DAX: IF((SUM(Table[SiteId])=28 || SUM(Table[SiteId])=52),"0.1%",[Att Rate])

 

This returns the correct result of 0.1% for Site 28, however for Site 52 - the normal Att Rate is returned, instead of the desired result of 0.1%.

 

Can anyone see what the problem is here? I must have made an oversight somewhere but cannot see where!

 

Any help would be greatly appreciated. Thanks!

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Try replacing your SUM(s) with MAX(s)?

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
harry843
New Member

Thank you everyone for your insight. Your solutions are all much appreciated, however replacing SUM with MAX using my original DAX gave me the required solution.

I'm guessing you had 1 row for 28 and multiple for 52, right? 🙂

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

Try replacing your SUM(s) with MAX(s)?

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
fhill
Resident Rockstar
Resident Rockstar

Does this have to be a Measure?  Here's the logic with a New Column instead?

 

New Column = IF(Table1[SiteID] = 28 || Table1[SiteID] = 52, .1, Table1[Rate])
 
image.png



Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




fhill
Resident Rockstar
Resident Rockstar

P.S.  Measure version if needed...

 

New Measure = IF( SUM(Table1[SiteID]) = 28 || SUM(Table1[SiteID]) = 52, .1, SUM(Table1[Rate]))
 
image.png



Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




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.