IIF Statement with Multiple condition

drew101

New Member
Joined
Jun 14, 2017
Messages
12
Cant figure out why i am unable to get the correct response if 3 conditions state Active then give me Active ,if they all do not give me Inactive

I am building this report from Excel to Access
I am trying to duplicate this code in Excel
Code:
=IF(COUNTIF(D47:F47,"Inactive"),"Inactive","Active")[code]
in access
This is what i have in access [code] Total Staus: IIf([Master COA STATUS]="Active" And [Active / Inactive]="Active" And [Paylocity and GL DEPT CODE]="Active","Active","Inactive") [code]
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
i am unable to get the correct response
You get either inactive or active when you shouldn't or you get something else, such as an error?
If the former, one of the values must not be what you think it is. The testing approach is to verify each value before evaluating the expression. How depends on where you are using this. Looks like a query...
 
Upvote 0
My apologies it has been a while and i agree.

Here is the Excel formula that works in Excel
Rich (BB code):
=IF(COUNTIF(D47:F47,"Inactive"),"Inactive","Active") 


In Access Query
Rich (BB code):
Expr1: IIf([Master COA STATUS]="Active" And [Active / Inactive]="Active" And [Paylocity and GL DEPT CODE]="Active","Active","Inactive")

This Code or Expression is not returning the correct value that i am looking for

Example If i have in Column 1 =The word "Active "and in Column 2 =Active and Column 3 =Inactive. then the return value should state Inactive because 1 out of the 3 words is not "Active".

i was able to get 1 out of 2 to work with
Rich (BB code):
Expr1: IIf([Master COA STATUS]="Active" And [Active / Inactive]="Active","Active","Inactive") 

I only do not receive the correct Value when it looks into all 3 and this is where i am asking for help.
 
Upvote 0
Obviously I don't have your exact tables but an expression similar to yours works as expected.
I still don't know if your problem relates to all calculations for every record or just some records. Still guessing, but looks more and more like this is in a query so again, you have to be sure if all the field values in the records are as you expect. Maybe remove the calculated field so that the query still applies whatever criteria you have and run it and check those values.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
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