Solved Group by Year and Month - Crosstab Query

jack555

Member
Local time
Today, 09:22
Joined
Apr 20, 2020
Messages
93
Would like to compare the monthly figures against each year. Have a totals/crosstab query grouped at month level like below.

2020-01 25
2020-02 50
2020-03 40
2021-01 20
2021-02 25
2021-03 35

However, I would like to have this in the below format

Month20202021
12520
25025
34035

Tried crosstab with year and month in column and row heading but got as per screenshot. How can we do this in a better way

1616330327133.png
 
Hi. I created the following table.

1616337465301.png


And that resulted in this crosstab query.

1616337609121.png
 
You have to use a numeric month to sort by otherwise your year will start with april. You can sort by the number but show the text.
 
You have to use a numeric month to sort by otherwise your year will start with april. You can sort by the number but show the text.
Oops, didn't see that. Thanks for the reminder. I guess I could try again when I get back in the office.

Cheers!

Sent from phone...
 
suspect the OP's crosstab is not correctly designed - perhaps there is another hidden grouped field as a row heading which is separating the years since the months are repeating
 
Oops, didn't see that. Thanks for the reminder. I guess I could try again when I get back in the office.

Cheers!

Sent from phone...
So, I adjusted the table like so.

1616372972357.png


And now, it comes out like this.

1616373002352.png
 
suspect the OP's crosstab is not correctly designed - perhaps there is another hidden grouped field as a row heading which is separating the years since the months are repeating
Thank you. found the problem. using "yyyy-mm" format for sorting, this was the hidden field. Thanks for the clue. Now problem solved.
 
Thank you. It worked for me. I tested creating a totals query and generating crosstab from the total query. your sample was an eye-opener for me.
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom