Measure for IF not working

misstoffeepenny

New Member
Joined
Jan 18, 2021
Messages
19
Office Version
  1. 365
  2. 2016
  3. 2011
Platform
  1. Windows
Hi all, I'm trying to write a DAX for an IF function where there are multiple criteria and true answers but it keeps getting stuck and generating on 1 answer for all outcomes any help correcting it would be appreciated.
NB all my tables are linked in data relationships.
Below is what I have so far:
=IF (
MAX ( SiteInspections[count major] ) > 1, 0,
IF (
MAX ( SiteInspections[count major] ) <= 1, 5,
IF (
MAX ( SiteInspections[count minor] ) > 5, 5,
IF (
MAX ( SiteInspections[count minor] ) <= 5, 10,
IF (
MAX ( SiteInspections[count minor] ) < 1, 15,
IF (
MAX ( SiteInspections[count OFI] ) > 5, 15,
IF (
MAX ( SiteInspections[count OFI] ) <= 5, 20, BLANK()
)
)
)
)
)
)
)

this gives all answers as 5... please help
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
IF will stop with the first test that is true, so you need to order the tests accordingly. Currently if this is true:

MAX( SiteInspections[count minor] ) > 5

it will never consider any of the criteria after that. It's not clear from your questions what priority any of them have over the others or what combinations are needed (though obviously testing for the MAX count minor being <1 after testing for it being <=5 is never going to return the second option)
 
Upvote 0
IF will stop with the first test that is true, so you need to order the tests accordingly. Currently if this is true:

MAX( SiteInspections[count minor] ) > 5

it will never consider any of the criteria after that. It's not clear from your questions what priority any of them have over the others or what combinations are needed (though obviously testing for the MAX count minor being <1 after testing for it being <=5 is never going to return the second option)
RoryA, thank you for your reply, I am still learning the DAX/ power pivot abilities

1. this order is the most important as major is a 'red flag', minor is amber, ofi is green etc.
2. with this formula even cells which have no data to look up are giving me a value of 5.
3. I've removed that line from the formula & refreshed it & again all still getting 5.
 
Upvote 0
That would suggest that count major is setting it - anything <=1 (including 0) would cause that.
 
Upvote 0
That would suggest that count major is setting it - anything <=1 (including 0) would cause that.
thank you for your help, this made me realise I needed to write in a >0 statement as well. so I managed to fix it with:

=IF(
MAX(SiteInspections[count major]) > 1, 0,
IF(
MAX(SiteInspections[count major]) = 1, 5,
IF(
MAX(SiteInspections[count minor]) > 5, 5,
IF(
AND(MAX(SiteInspections[count minor]) > 0, MAX(SiteInspections[count minor]) <= 5), 10,
IF(
MAX(SiteInspections[count OFI]) > 5, 15,
IF(
AND(MAX(SiteInspections[count OFI]) > 0, MAX(SiteInspections[count OFI]) <= 5), 20,
BLANK()
)
)
)
)
)
)
 
Upvote 0
You shouldn't really need the ANDs since the criteria immediately before each one have already ruled out anything over 5:

Excel Formula:
=IF(
MAX(SiteInspections[count major]) > 1, 0,
IF(
MAX(SiteInspections[count major]) = 1, 5,
IF(
MAX(SiteInspections[count minor]) > 5, 5,
IF(
MAX(SiteInspections[count minor]) > 0, 10,
IF(
MAX(SiteInspections[count OFI]) > 5, 15,
IF(
MAX(SiteInspections[count OFI]) > 0, 20,
BLANK()
)
)
)
)
)
)
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,116
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top