MattioMatt
Registered User.
- Local time
- Today, 14:30
- Joined
- Apr 25, 2017
- Messages
- 99
Counting records in query but returning a defined score rather than count value
I'm in need of some guidance..
I'm currently constructing a query. At the moment I'm pulling AppID and App Name from the 'tbl_App_Inventory' table - I'm wanting to link pull a field [MissedSLA] which is a text field for simply 'y' or 'n' from another table, tbl_App_Issues.
What I'd like to do is to have an expression that looks to count the number of 'Y's per app, if it is higher than zero to then give me a score of '9'. If there are no 'Y's then to look at 'N's, again counting to see if there is any, if the count is higher than Zero to then return '2' and for for a false to return '0'.
I've tried a number of ways to acheive this without success so far. I've tried importing the table tbl_App_Issues into my query with tbl_App_Inventory and linking via AppID but what I'm finding is, it will then list duplicates of the app name due to there being multiple issues per app. This is not the desired outcome, I've like to have one listing of my app name and then the column to be 'SLAScore' and just return 9/2/0 based on the above.
I've also tried to remove the tbl_App_Issues from my query and use an expression with IIF statements but I find it returns '9' no matter what I do.
I've tried this expression whilst linking the AppID for both tables in my query:
The result here is, it simply just returns 9 for everything even if there is no issues which have missed SLA.
I then created a seperate query to use the to count the 'y' 'n' by using the Count under Total. I used the AppID, App Name and MissedSLA field twice, one to display and one to do the CountofMissedSLA - thinking I could then use the expression to look up that why
I then tried to get my output this way:
This however just returns '0' for everything.
I've attached an example of the data I'm using and the desired output to my query.
I'm in need of some guidance..
I'm currently constructing a query. At the moment I'm pulling AppID and App Name from the 'tbl_App_Inventory' table - I'm wanting to link pull a field [MissedSLA] which is a text field for simply 'y' or 'n' from another table, tbl_App_Issues.
What I'd like to do is to have an expression that looks to count the number of 'Y's per app, if it is higher than zero to then give me a score of '9'. If there are no 'Y's then to look at 'N's, again counting to see if there is any, if the count is higher than Zero to then return '2' and for for a false to return '0'.
I've tried a number of ways to acheive this without success so far. I've tried importing the table tbl_App_Issues into my query with tbl_App_Inventory and linking via AppID but what I'm finding is, it will then list duplicates of the app name due to there being multiple issues per app. This is not the desired outcome, I've like to have one listing of my app name and then the column to be 'SLAScore' and just return 9/2/0 based on the above.
I've also tried to remove the tbl_App_Issues from my query and use an expression with IIF statements but I find it returns '9' no matter what I do.
I've tried this expression whilst linking the AppID for both tables in my query:
Code:
IIf(DCount("[tbl_App_Issues].[MissedSLA]", "tbl_App_Issues", "[tbl_App_Issues].[MissedSLA]='Y'")>0,9,IIf(DCount("[tbl_App_Issues].[MissedSLA]", "tbl_App_Issues", "[tbl_App_Issues].[MissedSLA]='N'")>0,2,0))
I then created a seperate query to use the to count the 'y' 'n' by using the Count under Total. I used the AppID, App Name and MissedSLA field twice, one to display and one to do the CountofMissedSLA - thinking I could then use the expression to look up that why
I then tried to get my output this way:
Code:
IIf(Dlookup("[MissedSLA]","Qry_Count_Missed_SLA","[Qry_Count_Missed_SLA].[AppID] = [tbl_App_Inventory].[AppID]")="Y",9,IIf(Dlookup("[MissedSLA]","Qry_Count_Missed_SLA","[Qry_Count_Missed_SLA].[AppID] = [tbl_App_Inventory].[AppID]")="N",2,0))
I've attached an example of the data I'm using and the desired output to my query.
Attachments
Last edited: