Query Quarter Function in Non-Calendar Fiscal Year Data (Google Sheets)

Let me share a secret with you on how to use the Query Quarter function in non-calendar fiscal year data in Google Sheets. It’s a simple yet powerful tool that can make your data analysis a breeze.

Understanding the Query Quarter Function

Before we dive into the details, let’s get familiar with the basics. The Quarter() function in Google Sheets Query is designed to summarize or extract data based on the calendar fiscal year. However, it might not be suitable for non-calendar fiscal year data.

In some countries, the fiscal year differs from the calendar year. For example, it could start from April and end in March or even have different start and end months depending on the country. This variation adds complexity when using the Query Quarter function.

Working with Calendar Year Data

Let’s start by exploring how to use the Query Quarter function without changing the periods, i.e., in a calendar year. This will help us better comprehend its functionality.

To begin, I’ll share two formulas with you. One formula summarizes the data based on quarters, while the other extracts specific rows of data based on quarters.

Sample data for calendar year quarters

The first formula allows you to populate data based on the desired quarter. For example, if you want data from January to March (Q1), you can use the following formula:

=query(A1:E, "Select * where quarter(A)="&G2&"")

By changing the value in cell G2 to 2, 3, or 4, you can extract data from different quarters (Q2, Q3, Q4) accordingly.

The second formula helps summarize data based on quarters. It provides a quarter-wise, product-wise summary, as shown in the example below:

Query summary - Q1, Q2, Q3, and Q4 wise

=query(A1:E, "Select quarter(A),B,sum(E) where A is not null group by quarter(A),B")

These formulas come in handy when dealing with calendar year data. It’s essential to understand their functionality before we move on to non-calendar fiscal year data.

Query Quarter Function in Non-Calendar Fiscal Year Data

Now, let’s address the main question – can we use the Query Quarter function in non-calendar fiscal year data? The answer is yes, but with a small twist.

For extracting or populating rows in non-calendar fiscal year data, we require a helper column. However, for summarizing data, a helper column is not necessary.

Consider the sample data below, which represents a non-calendar fiscal year starting from April to March:

Query Quarter in Non-Calendar Fiscal Year Data

To populate data based on the desired quarter, we need to convert the non-calendar year quarter to a calendar year quarter virtually. We can achieve this using the SWITCH function. Let me explain further.

Suppose you have the quarter number in cell G2 (e.g., in the example sheet “FY Mar Apr”). We can use the following SWITCH formula to convert it to a calendar year quarter:

=switch(G2, 4, 1, 1, 2, 2, 3, 3, 4)

By combining this formula with the Query function, you can populate data based on the desired quarter:

=query(A1:E, "Select * where quarter(A)="&switch(G2, 4, 1, 1, 2, 2, 3, 3, 4))

If the fiscal year is from July to June, use the following SWITCH formula instead:

=switch(G2, 3, 1, 4, 2, 1, 3, 2, 4)

For summarizing data in non-calendar fiscal year datasets, using a helper column would be beneficial.

Before creating the summary, don’t forget to add the following formula in cell F1, depending on your fiscal year:

For FY Apr-Mar:

= {"Quarter"; ArrayFormula( if( Len(A2:A), switch(ROUNDUP(month(A2:A)/3,0),1,4,2,1,3,2,4,3), ) ) }

For FY Jul-Jun:

= {"Quarter"; ArrayFormula( if( Len(A2:A), switch(ROUNDUP(month(A2:A)/3,0),1,3,2,4,3,1,4,2), ) ) }

Finally, use the Query function to summarize the data based on quarters:

=Query( A1:F, "Select F,B,sum(E) where A is not null group by F,B" )

And voila! You have successfully used the Query Quarter function in non-calendar fiscal year data in Google Sheets.

If you want to learn more about data analysis in Google Sheets, check out Crawlan.com for valuable resources.

Remember, these tips can save you time and effort when working with non-calendar fiscal year data. Enjoy exploring the endless possibilities of data analysis in Google Sheets!

Resources:

Related posts