Crosstab Query with two values (1 Viewer)

Lkwdmntr

Registered User.
Local time
Today, 00:23
Joined
Jul 10, 2019
Messages
277
Hello,

I am trying to create a crosstab query that has two values under the cross tab columns. I am attaching an excel file that shows what I am looking to accomplish. The first sheet has the data and how it comes up in the query I made and the second sheet shows how I am hoping to get the new query result.
 

Attachments

  • Data.zip
    17 KB · Views: 80

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:23
Joined
Feb 19, 2002
Messages
43,233
A crosstab query can only pivot a single column at a time. If you want to do multiples, create a separate crosstab for each column then create a final query that joins all the crosstabs. You will have to alias the columns as you select them because all the crosstabs will have the same column name.
 

Lkwdmntr

Registered User.
Local time
Today, 00:23
Joined
Jul 10, 2019
Messages
277
Having a hard time grasping this. I did make the two separate crosstab queries, but not sure how to combine them. I uploaded a new cutdown version of my database on google drive.

 

June7

AWF VIP
Local time
Yesterday, 23:23
Joined
Mar 9, 2014
Messages
5,466
As long as the two queries have exactly same User, Index, Action values, join them.

SELECT Planned_Crosstab.UserID, Planned_Crosstab.Index, Planned_Crosstab.Action, Actual_Crosstab.[1], Actual_Crosstab.[2], Actual_Crosstab.[3], Actual_Crosstab.[4], Actual_Crosstab.[5], Actual_Crosstab.[6], Actual_Crosstab.[7], Actual_Crosstab.[8], Actual_Crosstab.[9], Actual_Crosstab.[10], Actual_Crosstab.[11], Actual_Crosstab.[12], Planned_Crosstab.[1], Planned_Crosstab.[2], Planned_Crosstab.[3], Planned_Crosstab.[4], Planned_Crosstab.[5], Planned_Crosstab.[6], Planned_Crosstab.[7], Planned_Crosstab.[8], Planned_Crosstab.[9], Planned_Crosstab.[10], Planned_Crosstab.[11], Planned_Crosstab.[12]
FROM Actual_Crosstab INNER JOIN Planned_Crosstab ON (Actual_Crosstab.Action = Planned_Crosstab.Action) AND (Actual_Crosstab.Index = Planned_Crosstab.Index) AND (Actual_Crosstab.UserID = Planned_Crosstab.UserID);
 

Users who are viewing this thread

Top Bottom