How to use query to generate the result with descending order - google-sheets

Hi I would like to generate the result with descending order.
is it possible to use Query achieve this result? or is there alternative way ?
Thank you
https://docs.google.com/spreadsheets/d/1hnFi-5IRIb-hSO2YffvjR9ZETL11c8wVuCbBhC5m7qY/edit?usp=sharing

use:
=INDEX(QUERY(SPLIT(FLATTEN(A2:A&"×"&B1:D1&"×"&B2:D), "×"),
"where Col3 is not null order by Col3 desc", ))

Related

Why am I getting a value error in my google sheets query?

I took an Udemy class in Google Sheets and I'm trying a formula on a similar dataset as I learned on, but I'm getting a value error. Please help.
The query is:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1uJAwHzcg_MYBS08jqnWGcqe7oBIlPyVWCQN48G6tFfE/edit#gid=790495475","sephora_website_dataset2!$A:$G"),"SELECT Col2,Average(Col7) WHERE Col2 IS NOT NULL GROUP BY Col2 ORDER BY Average(Col7) desc LIMIT 10",-1)
Here is what the dataset looks like: https://i.stack.imgur.com/Qm6qx.png
It doesn't know Average, use avg instead.
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1uJAwHzcg_MYBS08jqnWGcqe7oBIlPyVWCQN48G6tFfE/edit#gid=790495475","sephora_website_dataset2!$A:$G"),"SELECT Col2,avg(Col7) WHERE Col2 IS NOT NULL GROUP BY Col2 ORDER BY avg(Col7) desc LIMIT 10",-1)
The name of the average-function in your query is avg, not "Average".
So the correct formula would be:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1uJAwHzcg_MYBS08jqnWGcqe7oBIlPyVWCQN48G6tFfE/edit#gid=790495475","sephora_website_dataset2!$A:$G"),"SELECT Col2, avg(Col7) WHERE Col2 IS NOT NULL GROUP BY Col2 ORDER BY avg(Col7) desc LIMIT 10", -1)
use:
=QUERY(IMPORTRANGE("1uJAwHzcg_MYBS08jqnWGcqe7oBIlPyVWCQN48G6tFfE", "sephora_website_dataset2!A:G"),
"select Col2,avg(Col7)
where Col2 is not null
group by Col2
order by avg(Col7) desc
limit 10
label avg(Col7)''", 0)

What formula can be used to find unique value in two data in google sheet?

I am trying to find two unique names in two data. Could you kindly advise what formula can be used? Thank you so much
https://docs.google.com/spreadsheets/d/1lkLSmrbln3ZIZSIe25A48nH6931LzQ8DnLmfI_3jsMQ/edit?usp=sharing
try:
=QUERY(QUERY(FLATTEN(A2:B),
"select Col1,count(Col1) where Col1 is not null group by Col1"),
"select Col1 where Col2 = 1")

Query to list data that's not listed in another column

=QUERY({startingdates!D2:D, Cancelledtours!D2:D},"Select Col1 where not(Col1) matches Col2")
This seems to work for Column A but not column D. I'm at a dead-end. Can anyone help?
Sheet- https://docs.google.com/spreadsheets/d/1zEQmNs48CsaaioQOcwuK97kcmnDLDfX-57nuXFaLujc/edit?usp=sharing
You have to do a lookup on the starting date - the query as it stands only looks in the same row to see if there is a match:
=ArrayFormula(QUERY({StartingDates!D2:D, isnumber(vlookup(StartingDates!D2:D,CancelledTours!D2:D,1,false))},"Select Col1 where Col2=false"))
or slightly shorter using match:
=ArrayFormula(QUERY({StartingDates!D2:D, isnumber(match(StartingDates!D2:D,CancelledTours!D2:D,0))},"Select Col1 where Col2=false"))
Reversing the logic, this also works:
=ArrayFormula(QUERY({StartingDates!D2:D, isna(match(StartingDates!D2:D,CancelledTours!D2:D,0))},"Select Col1 where Col2=true"))
try:
=FILTER(startingdates!D2:D, NOT(COUNTIF(Cancelledtours!D2:D, startingdates!D2:D)))

Query Col1 > today()

When I use the format that I left below, returns in error, I know that something is missing adjusting in relation to WHERE AND... But I could not fit to supply the error.
I would like some help knowing what I missed.
"select Col1,Col2,Col3 where Col1 is not null Order by Col1, Col2 AND Col1 > date'"&TEXT(today()-1,"yyyy/mm/dd")&"'"
The date and time for Col1 and Col2 are like this:
With this formula, I hope I can filter the imported data only for those that have the date of the current day or tomorrow and that today's games are higher than the current time.
Link to spreadsheet:
https://docs.google.com/spreadsheets/d/15T4UPVtEHv43DLomKcTmdaPuGWMsBUoO7bLvlOhab4k/edit?usp=sharing
Formula set in Página1 G2
it may look like you can combine parameters as you like but there is a specific order that needs to be followed:
respectively joining operator like and needs to be proceeded by parent parameter where:
Try:
"select Col1, Col2, Col3 where Col1 >='"&TEXT(TODAY()-1,"yyyy-mm-dd")&"' and Col1 is not null Order by Col1, Col2"
This returns 78 records

Is there a way to combine formula?

I'm making a bonus model for work. There are a lot of article numbers that the sheet has to check.
Right now I'm using this:
=SUMIFS(Data!$K$2:$K;Data!$I$2:$I;AA$2;Data!$G$2:$G;$A14)+
SUMIFS(Data!$K$2:$K;Data!$I$2:$I;AB$2;Data!$G$2:$G;$A14)+
SUMIFS(Data!$K$2:$K;Data!$I$2:$I;AC$2;Data!$G$2:$G;$A14)+
SUMIFS(Data!$K$2:$K;Data!$I$2:$I;AD$2;Data!$G$2:$G;$A14)
etc
etc
Is there a way to combine everything in one Formula? AA2:AD2 doesn't work...
I hope I'm explaining it right :)
https://docs.google.com/spreadsheets/d/e/2PACX-1vRO-4tOpgZD97cvDEAjoCz-xK-7YhrjpzRlUBplpXOrwgssE2VYjuzdX3oBZdbNVk924J6La-Vy-52_/pubhtml
I'm confused with how your data works a bit. But am I right that you want to check for each salesperson if they sold any of the article numbers, and if that's the case sum the column C?
Like so?
Formula I used translates to:
{=SUMPRODUCT(($A$2:$A$107=F2)*($B$2:$B$107=TRANSPOSE($E$2:$E$15))*($C$2:$C$107))}
And needs to be confirmerd through CtrlShiftEnter
How about :
=SUMIFS(Data!$K$2:$K;Data!$I$2:$I;AA$2;Data!$I$2:$I;AB$2;Data!$I$2:$I;AC$2;Data!$I$2:$I;AD$2;Data!$G$2:$G;$A14)
Still trying to find a way to combine criteria...
Well, played and depending what your data is, and if you can control it then something like this may help:
N9:
=QUERY({A3:C}, "select Col1,sum(Col3)
where Col1 is not null
group by Col1
label sum(Col3)''")
H9:
=TRANSPOSE(QUERY({A3:C}, "select Col1,sum(Col3)
where Col1 is not null
group by Col1
pivot Col2
label sum(Col3)''"))
E9:
=QUERY({A3:C}, "select Col2,sum(Col3)
where Col2 is not null
group by Col2
label sum(Col3)''")
E3:
=QUERY({A3:C}, "select Col1,sum(Col3)
where Col1 is not null
group by Col1
pivot Col2
label sum(Col3)''")

Resources