Home > Back-end >  Sort the merged data in google sheet
Sort the merged data in google sheet

Time:06-24

I am using the query to combine the data from multiple sheets enter image description here

However the data is getting auto sorted as per sheets, I want the data to be sorted as date.

Case scenario Data from different sheets are called as it available in the sheets, for e.g. Sheet 1 is having data of 1st June and 5th June and Sheet2 is having data of 2nd June. Data which are shown as combined are in this order: 1st June--5th June--2nd June.

Requirement

I want the data which are being called using query gets sorted automatically as per the date available in Column 1.

Is there any workaround for this issue?

CodePudding user response:

Try the following formula:

=QUERY({Sheet2!A1:C;Sheet3!A1:C;Sheet4!A1:C},"select * where Col2 is not 
null order by Col1")

Or alternatively, if you would like to sort with the most recent date first:

=QUERY({Sheet2!A1:C;Sheet3!A1:C;Sheet4!A1:C},"select * where Col2 is not 
null order by Col1 desc")

More information on order by can be found in Google's Query Language Reference documentation.

  • Related