My mistake --
SELECT tWhiteSpaceMatrixData.SundyneComp,
tWhiteSpaceMatrixData.SundynePump,
tWhiteSpaceMatrixData.Sunflo, tWhiteSpaceMatrixData.MasoSine,
tWhiteSpaceMatrixData.Ansimag, tWhiteSpaceMatrixData.HMDKontro,
tWhiteSpaceMatrixData.Marelli, Sum(IIf([SundyneComp]="N/A" OR
[SundyneComp]
Is Null,0,1)+ IIf([SundynePump]="N/A" OR [SundynePump] Is Null,0,1)+
IIF([Sunflo]="N/A" OR [Sunflo] Is Null,0,1)+ IIf([Ansimag]="N/A" OR
[Ansimag]
Is Null,0,1)+ IIf([HMDKontro] ="N/A" OR [HMDKontro] Is Null,0,1)+
IIf([MasoSine]="N/A" OR [MasoSine] Is Null,0,1)+ IIf([Marelli]="N/A" OR
[Marelli] Is Null,0,1)) AS AvailableSpaces
FROM tWhiteSpaceMatrixData
GROUP BY tWhiteSpaceMatrixData.SundyneComp,
tWhiteSpaceMatrixData.SundynePump, tWhiteSpaceMatrixData.Sunflo,
tWhiteSpaceMatrixData.MasoSine, tWhiteSpaceMatrixData.Ansimag,
tWhiteSpaceMatrixData.HMDKontro, tWhiteSpaceMatrixData.Marelli;
Pam said:
Karl,
I got the error message to go away, thanks to post from John Spencer "Any
fields that you aren't using SUM, Avg, etc on must be grouped by". Now,
it
just totals all seven fields across for each row - each row for
AvailableSpaces has 7 for the total, regardless of whether it is empty,
has
text, or NA.
Can you please help?
Thanks,
Pam
KARL DEWEY said:
Try this --
SELECT [Target 1], [Target 2], [Target 3], [Target 4],
Sum(IIF(Nz([Target
1],0)="N/A",0,1) + IIF(Nz([Target 2],0)="N/A",0,1) + IIF(Nz([Target
3],0)="N/A",0,1) + IIF(Nz([Target 4],0)="N/A",0,1)) AS AvailableSpaces
FROM YourTable;
:
Karl,
Thanks for the quick reply. I think I need some help tweeking the
solution
to fit application. I have the first query set with 10 Target fields
(columns) and will have approximately 15 rows of data for each Target.
I
grouped the data in the query and created a second query based on the
first
and entered in SQL view the statement you provided. It returned the
correct
answer, but I'm not sure how I can have AvailableSpaces total each
row.
Is
this possible?
I appreciate your help and if you could instruct me futher, I would
appreciate it.
Thanks,
Pam
Try this --
SELECT Sum(IIF(Nz([Target 1],0)="N/A",0,1) + IIF(Nz([Target
2],0)="N/A",0,1)
+ IIF(Nz([Target 3],0)="N/A",0,1) + IIF(Nz([Target 4],0)="N/A",0,1))
AS
AvailableSpaces
FROM YourTable;
:
Hi,
I have a query with several fields such as Target1; Target2;
Target3;
Target4 with data such as Activity, Goal, $Amts, and NA. I would
like
to
count all of these in one field "Available Spaces" for all non-null
values
but not "NA" values. As below:
Target1 Target 2 Target 3 AvailableSpaces
Activity Goal NA 2
10,000 NA Activity 2
(Blank) Activity NA 1
I've read thru posts and internet searches and can't seem to find
solution
needed. If anyone has an answer, it will be greatly appreciated.
Thanks in advance,
Pam