I have an Access database that has checkboxes in on of the tables. I need to get a Sum of the checkboxes but, I want to convert the checkbox columns into rows instead of columns.
Here is an example of how it appears in the table:
x
Name DND Other CAP SAP DAP EXP
Person One -1 -1 NULL NULL -1 -1
Person Two NULL -1 -1 -1 NULL NULL
Person Three NULL -1 -1 NULL NULL NUll
Here is how I want the report to display the data:
Discharge Count
DND 1
Other 3
CAP 2
SAP 1
DAP 1
EXP 1
I tried using a Case statement but, it didn’t come out correctly
Advertisement
Answer
Use a union query and check for Null:
Select
T.Discharge, Abs(Sum(T.[Count])) As DischargeCount
From
(Select "DND" As Discharge, [DND] Is Not Null As [Count] From YourTable
Union ALL
Select "Other" As Discharge, [Other] Is Not Null As [Count] From YourTable
Union ALL
Select "CAP" As Discharge, [CAP] Is Not Null As [Count] From YourTable
Union ALL
Select "SAP" As Discharge, [SAP] Is Not Null As [Count] From YourTable
Union ALL
Select "DAP" As Discharge, [DAP] Is Not Null As [Count] From YourTable
Union ALL
Select "EXP" As Discharge, [EXP] Is Not Null As [Count] From YourTable) As T
Group By
T.Discharge