It seems that we can not use Count (Distinct column) function in MS Access. I have following data and expected result as shown below
Looking for MS Access query which can give required result.
Data
ID Name Category Person Office
1 FIL Global Ben london
1 FIL Global Ben london
1 FIL Overall Ben Americas
106 Asset Global Ben london
156 ICICI Overall Rimmer london
156 ICICI Overall Rimmer london
188 UBS Overall Rimmer london
9 Fund Global Rimmer london
Expected Result
Person Global_Cnt Overall_Cnt
Ben 2 1
Rimmer 1 2
Use a subquery to select the distinct values from your table.
In the parent query,
GROUP BY Person, and use separateCount()expressions for each category.Count()only counts non-Null values, so useIIf()to return 1 for the category of interest and Null otherwise.I was unsure which fields identify your unique values, so chose
ID,Category, andPerson. The result set from the query matches what you asked for; change theSELECT DISTINCTfield list if it doesn’t fit with your actual data.