Forum Discussion
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!
- Try replacing your SUM(s) with MAX(s)?
5 Replies
- Greg_DecklerCommunity ChampionTry replacing your SUM(s) with MAX(s)?
- AnonymousNot applicable
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.
- Greg_DecklerCommunity ChampionI'm guessing you had 1 row for 28 and multiple for 52, right? 🙂
- fhillResident 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])- fhillResident Rockstar
P.S. Measure version if needed...
New Measure = IF( SUM(Table1[SiteID]) = 28 || SUM(Table1[SiteID]) = 52, .1, SUM(Table1[Rate]))