IFF function with Multi Criteria

jeannie Jones
jeannie Jones used Ask the Experts™
on
Im trying to create a nested IFF function to turn this excel function in access. The basic excel formula is =IFERROR(SUM(COUNTIFS('Import Report'!E:E,{"CM","MMNRO","MMROI","PMCM","PMINS","PMOR","PMPDM","PMREG","PMRT"},'Import Report'!K:K,">="&(A2-1/24),'Import Report'!K:K,"<"&(C2+23/24),'Import Report'!F:F,"*COMP*",'Import Report'!O:O,">="&(A2-1/24),'Import Report'!O:O,"<"&(C2+23/24),'Import Report'!X:X,"LEWMXTCHE"))/SUM(COUNTIFS('Import Report'!E:E,{"CM","MMNRO","MMROI","PMCM","PMINS","PMOR","PMPDM","PMREG","PMRT"},'Import Report'!K:K,">="&(A2-1/24),'Import Report'!K:K,"<"&(C2+23/24),'Import Report'!X:X,"LEWMXTCHE")),0)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
NorieAnalyst Assistant

Commented:
Can you explain, in words, what that 'basic' Excel formula is meant to do?:)

Also, in Access which fields would correspond to the Excel columns being used in the formula?
jeannie JonesDatabase Developer

Author

Commented:
my access table fields are as follows:
2018-09-18_13-13-39.jpg
jeannie JonesDatabase Developer

Author

Commented:
the formula that i have written on paper is this.
 status (COMP or FCOM) and ActualLaborhours(>0) and ActualStart date ( what ever dates the user puts in on the form{startDate and EndDate  [divided By\]

WorkType(PMINS,PMOR,PMPDM,PMREG,PMRT) and Status( not = CAN) And TargetStartDate(what ever dates the user puts in on the form{startDate and EndDate )
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Distinguished Expert 2017
Commented:
When you have compound conditions, you must repeat the field name so:

IIf((Status = "COMP" OR Status = "FCOM") AND (ActualLaborHours >0 And ActualStartDate Between Forms!yourform!StartDate And Forms!yourform!EndDate), SomeField / Nz(SomeOtherField, IIf(.... next If, true action, false action)  As CalcResult

Your explanation is fuzzy so I'm not going to try to build the rest of the IIf()

Just remember 2 things:
1. repeat the column name if you want to compare to multiple values
2. Enclose the parts of the criteria in parentheses to ensure that the expression is evaluated as you intend.

Access follows standard order of operation rules.

 a and b or c or d  is evaluated as (a and b) or c or d

whereas you probably want  a and (b or c or d)
Hamed NasrRetired IT Professional

Commented:
Upload the excel worksheet with few rows of data.
jeannie JonesDatabase Developer

Author

Commented:
i have uploaded  some sample data that is in my excel sheet
testdata.xlsx
Hamed NasrRetired IT Professional

Commented:
Im trying to create a nested IFF function to turn this excel function in access

Open in new window


So please upload the working excel worksheet showing a working function.
Fill the first row of the sheet with names for headings  as in the access table.
I assume you want to transfer the excel sheet to access table.

Also upload a demo of any database related to the issue.
jeannie JonesDatabase Developer

Author

Commented:
can you show me a rough draft of what this would look like in access Query designer please
Hamed NasrRetired IT Professional

Commented:
To be able to do that, one should understand the problem.
My previous request will make it easy for me to help.
Distinguished Expert 2017

Commented:
I showed you how it would look in  a query:

Select .... my sample, ....
Hamed NasrRetired IT Professional

Commented:
look like in access Query designer
  1. Name first row in excel with suitable column names.
  2. Get external data from Excel, and link to specified excel sheet.
  3. Open query designer and use the linked table as record source.
  4. Select related fields to create the select statement.
jeannie JonesDatabase Developer

Author

Commented:
I did that already and its not coming up with the right number that is on the excel sheet.
Hamed NasrRetired IT Professional

Commented:
I did that already and its not coming up with the right number that is on the excel sheet.

The question will bloat if we keep uncovering new information after few comments.

So speed up the solution to the issue, upload what you have done, in access and excel, to investigate.
Try that with a spreadsheet with few (3-5) columns.
jeannie JonesDatabase Developer

Author

Commented:
SELECT Count(*) AS LEW
FROM MaximoReportT
WHERE (((MaximoReportT.Status)="COMP") AND ((MaximoReportT.ActualLaborHours)>"00:00") AND ((MaximoReportT.ActualStartDate) Between [Enter the Start Date] And [Enter the End Date])) OR (((MaximoReportT.Status)="FCOMP"));

UNION SELECT Count(*) AS LEW
FROM MaximoReportT
WHERE ((WorkType) In ("PMINS","PMOR","PMPDM","PMREG","PMRT")) AND ((Status)<>"CAN") AND (TargetStartDate) Between [Enter the Start Date] And [Enter the End Date];
 
Here the query i got so far and it returns a value off 133/608  now i need to get those numbers into a percentage. i have attached the database it self
MaximoAnylyzer11--Edit-.accdb
Hamed NasrRetired IT Professional

Commented:
Thanks for the uploaded file.
It has many objects.
I ran union query UnionPMCOMPQ, and got:
LEW
0
1950

 so what shall I look for and what to expect,
jeannie JonesDatabase Developer

Author

Commented:
run the query that says Union
jeannie JonesDatabase Developer

Author

Commented:
and now i trying to figure out from the union query how i can get it to calculate the percentage between those numbers
Hamed NasrRetired IT Professional

Commented:
I did.
What is the expected result?

Upload the excel sheet. Make sure the column titles are the same as the excel table.
jeannie JonesDatabase Developer

Author

Commented:
all I am trying do Is get this in access to have the same calculations as the dash sheet in excel
DASH-Details---Simple.xlsm
Hamed NasrRetired IT Professional

Commented:
Thanks!
I was expecting to narrow down the scope.

Anyway I'll give it a try sometime later.

In the mean time other experts may join in.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial