Skip to content
Advertisement

Amend Report to use financial years and quarters

I need to amend this existing code to group by financial year (starts 1 July) and quarters, I realize that it is the below part of the query that requires amending but I can’t get it to work

The full query is

Sample data

Lyaout as per below but with finacial yaer ^ qtrs shown instead of months

Report layout

Advertisement

Answer

Below is the code for computing quarter and year_quarter columns. Since you did not provide the exact definition of quarter notation, I did both possibilities (starting from January (def. 1) or July (def. 2)).

Note the year - 1 in the year_quarter_2 definition when starting from July. This ensures that 2018Q3 is chronically later than 2018Q2, which makes more sense like how school quarters are defined. You may change them easily if you use a different definition.

Code:

Output (duplicate rows are ignored):

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement