Search code examples
sortinggoogle-sheetsfilteruniquegoogle-query-language

Append the results of to 'Unique' formulas and order by date in google sheets


I have two Goole Sheet queries which both work as required my remaining challenge is to combine the results of both and order by date. my two queries are:

=UNIQUE(FILTER({'My Data'!B13:B, 'My Data'!F13:F, 'My Data'!N13:N, 'My Data'!L13:L, 'My Data'!L13:L * 24 * 'My Data A'!K2 }, 
'My Data'!O13:O = "Y", 
'My Data'!Q13:Q =G2,
MONTH('My Data'!B13:B) =E2, 
YEAR('My Data'!B13:B) =C2
))

and

=UNIQUE(FILTER({'My Data 2'!A4:A, 'My Data 2'!E4:E, 'My Data 2'!D4:D, 'My Data 2'!F4:F,'My Data 2'!F4:F * 24 * 'My Data 2'!G4:G}, 
'My Data 2'!C4:C =G2, 
MONTH('My Data 2'!A4:A) =E2, 
YEAR('My Data 2'!A4:A) =C2
))

I can not see a way of doing what I require other than creating an extra sheet with both queries on and then querying that sheet but these still doesn't give me what I need!

Is there a way or an approach to do this in sheets?


Solution

  • try:

    =SORT({UNIQUE(FILTER({'My Data'!B13:B, 'My Data'!F13:F, 'My Data'!N13:N, 'My Data'!L13:L, 'My Data'!L13:L * 24 * 'My Data 2'!K2 }, 
    'My Data'!O13:O = "Y", 
    'My Data'!Q13:Q =G2,
    MONTH('My Data'!B13:B) =E2, 
    YEAR('My Data'!B13:B) =C2
    ));
    UNIQUE(FILTER({'My Data 2'!A4:A, 'My Data 2'!E4:E, 'My Data 2'!D4:D, 'My Data 2'!F4:F,'My Data 2'!F4:F * 24 * 'My Data 2'!G4:G}, 
    'My Data 2'!C4:C =G2, 
    MONTH('My Data 2'!A4:A) =E2, 
    YEAR('My Data 2'!A4:A) =C2
    ))})
    

    update:

    =SORT({UNIQUE(FILTER({'My Data'!B13:B, 'My Data'!F13:F, 'My Data'!N13:N, 
     'My Data'!L13:L, 'My Data'!L13:L * 24 * Totals!K2 }, 'My Data'!O13:O = "Y", 
    'My Data'!Q13:Q =G3, MONTH('My Data'!B13:B) =E3, YEAR('My Data'!B13:B) =C3));
     UNIQUE(FILTER({'Non Log'!A4:A, 'Non Log'!E4:E, 'Non Log'!D4:D, 'Non Log'!F4:F,
     'Non Log'!F4:F * 24 * 'Non Log'!G4:G}, 'Non Log'!C4:C =G3, 
     MONTH('Non Log'!A4:A) =E3, YEAR('Non Log'!A4:A) =C3))}, 1, 0)
    

    enter image description here