I have a query that returns data like this:
Store Product CasesPerStore
Bob's Original 2
Bob's Super 1
Tom's Original 5
Pete's Original 9
Pete's Super 2
And I want to join it to another query by Store, to end up with this:
Other query headings.... Store Original CasesPerStore Super CasesPerStore
Other query data........ Bob's 2 1
Other query data........ Tom's 5
Other query data........ Pete's 9 2
I can do this to the original data using a crosstab query, but I then can’t reference the new crosstab headings (e.g. [Original CasesPerStore] and [Super CasesPerStore]) in a join, probably because they are dynamic i.e. the headings could change depending on what products are in the data at that point.
So how can I join to this ‘rotated’ data?
If you know in advance how many products there are, and they are permanently fixed, then this simplistic solution may be enough. By using
Iifstatements you can get around the pivoting of data but it’s hard-coded SQL.