You can, sometimes, with a trick, or, more general, doing two crosstabs and
next, in a third query, join them on the first two on their StepName.
The trick, once explained by Duane, I think, is to get a table, one field,
f1, with two records, one field, values 1 and 2, for simplicity, then:
TRANSFORM Nz(SUM( iif(f1=1, AmountOfDefects, OtherFieldName) ), 0)
SELECT stepName
FROM originalTable, tableWithTwoRecords
GROUP BY stepName
PIVOT DefectName & "_" & f1
Hoping it may help,
Vanderghast, Access MVP
> Thanks again, and one more question:
>
[quoted text clipped - 76 lines]
>>
>> > Thanks.
kramer31 - 21 Mar 2007 19:33 GMT
Hi. Thanks for all of your help. I really appreciate it. I got most
of the crosstab stuff to work except for the IN clause.
I get the error:
"Data type mismatch in criteria expression."
from the following query:
TRANSFORM Nz(SUM(Detected_Value), 0)
SELECT Phase_Data_IJ_Project_Data_DefectInfo.Project_Id,
Phase_Data_IJ_Project_Data_DefectInfo.Project_Name,
Phase_Data_IJ_Project_Data_DefectInfo.Phase_Id,
Phase_Data_IJ_Project_Data_DefectInfo.Phase_Name
FROM Phase_Defects RIGHT JOIN Phase_Data_IJ_Project_Data_DefectInfo ON
Phase_Defects.Phase_Id=Phase_Data_IJ_Project_Data_DefectInfo.Phase_Id
GROUP BY Phase_Data_IJ_Project_Data_DefectInfo.Project_Id,
Phase_Data_IJ_Project_Data_DefectInfo.Project_Name,
Phase_Data_IJ_Project_Data_DefectInfo.Phase_Id,
Phase_Data_IJ_Project_Data_DefectInfo.Phase_Name,
Phase_Data_IJ_Project_Data_DefectInfo.Project_Id,
Phase_Data_IJ_Project_Data_DefectInfo.Project_Name
PIVOT Phase_Data_IJ_Project_Data_DefectInfo.DefectTypeID
IN('Type1Defects', 'Type2Defects', 'Type3Defects', 'Type4Defects',
'Type5Defects', 'Type6Defects', 'Type7Defects');
When I take out the IN clause, it works just fine and there are
exactly 7 unnamed columns. I've tried both single and double quotes,
but no luck.
Any further help would be much appreciated.
> You can, sometimes, with a trick, or, more general, doing two crosstabs and
> next, in a third query, join them on the first two on their StepName.
[quoted text clipped - 95 lines]
>
> >> > Thanks.
Michel Walsh - 21 Mar 2007 22:32 GMT
It is quite unusual to get un-named columns with a crosstab... you can get
<> if the PIVOT expression is null, but SEVEN un-named columns imply Jet
see 7 different 'things' as pivot. Your field
Phase_Data_IJ_Project_Data_DefectInfo.DefectTypeID
is really a string? or is it a number that is DISPLAYED (formatted) as a
string through a LOOKUP ?
Vanderghast, Access MVP
> Hi. Thanks for all of your help. I really appreciate it. I got most
> of the crosstab stuff to work except for the IN clause.
[quoted text clipped - 135 lines]
>>
>> >> > Thanks.
Kramer - 22 Mar 2007 00:28 GMT
Never mind, I figured it out. I just have to make sure that IN
contains the actual column names. You are also right. They are
named. I was pivoting on the wrong variable which was giving me
numbers rather than the strings I was expecting.
On Mar 21, 2:32 pm, "Michel Walsh"
<vanderghast@VirusAreFunnierThanSpam> wrote:
> It is quite unusual to get un-named columns with a crosstab... you can get
> <> if the PIVOT expression is null, but SEVEN un-named columns imply Jet
[quoted text clipped - 150 lines]
>
> >> >> > Thanks.