Avoid auto sorting in Google Sheets Query - google-sheets

I am facing the issue, that during a query I get auto sorting of the group of results. The code is following:
=QUERY('Sheet1'!A1:H;"select A, sum(H) where A is not null group by A ";1)
I would like to keep the original order of elements and not want to get a sorted list.
I would appreciate any help in this topic.
Thank you in advance.

An easier way is this. You can use Filter, Unique and Sumif.
={unique(filter(DB!A:A,DB!A:A<>"")),arrayformula(SUMIF(DB!A:A,unique(filter(DB!A:A,DB!A:A<>"")),DB!H:H))}
Ciao #Terio
In my video I learn how these functions are used with SUMIF. But it's in Italian 😊: https://youtu.be/aEMrczLlwrE

This do what you want
=ARRAYFORMULA({FILTER(UNIQUE('PH1'!A1:A);UNIQUE('PH1'!A1:A)<>"")\ARRAY_CONSTRAIN(SUMIF('PH1'!A1:A;UNIQUE('PH1'!A1:A);'PH1'!H1:H);ROWS(FILTER(UNIQUE('PH1'!A1:A);UNIQUE('PH1'!A1:A)<>""));1)})
maybe I can simplify them, but work and not apply a sort to A,
ask for more if you need

Related

Is there a way to remove entries based on condition in =filter?

Image of google sheets:
I probably did not phrase my question accurately. Is there a way to remove the result 'a' because it fulfils the '<>1' condition? I am pretty sure a mixture of query and arrayformula is needed but I can't figure it out.
I am aware I can split it into multiple columns to achieve what I want but I am looking for a solution that requires only 1 formula.
More information would be helpful here, but if I understand your screenshot correctly you should be able to do this easily with the QUERY or FILTER function. Below is a query sample that would satisfy your >3 filter requirement
=QUERY(A1:B20, "SELECT B WHERE A > 3")
Where A1:B20 is your data range

Respond with an error if dates and names overlap with each other

I think my brain is going to explode. I must be thinking about this to much.
I'm trying to make a spreadsheet to keep track of apartments and cars for a construction project. We only have so many cars and so many apartments. Im trying to schedule subcontractors so they don't overlap with each others apartments and cars.
Here is the code I have so far...
=IF(ARRAYFORMULA(B:B)=Data!$A$1,IF(DATEVALUE(D17)>=DATEVALUE(D18),IF(DATEVALUE(E18)>=DATEVALUE(E17),"Ok","Overlap")"Ok","Overlap"),"")
Please see my spreadsheet here for a better example of what I am looking for.
https://docs.google.com/spreadsheets/d/17t_8nhKfu3vy3OpAWZ_6Ep5Xn-4kwo8Xo4E6WuYVbFY/edit?usp=sharing
Thank you so much in advance!!!
You can try the formula below and paste it on the H3 cell for example. Afterwards, you will have to drag it down the column such that all the entries are covered.
As for the formula, it makes use of IF and COUNTIFS in order to check the conditions:
=IF(COUNTIFS(B$3:B3,B3,D$3:D3,"<="&D3,E$3:E3,">="&D3)>1,"Date Overlap",IF(COUNTIFS(C$3:C3,C3,D$3:D3,"<="&D3,E$3:E3,">="&D3)>1,"Vehicle Overlap","Ok"))
Reference
COUNTIFS function;
IF function.

Simple frequency distribution chart or formula (Google Sheets)

Have used this forum to help solve a few spreadsheet issues in the past (so many thank for all the donated time and expertise).
Hoping the community can help with something that thought initially to be quite simple but I can't find the answer or solution anywhere.
I have a list of values and I want to create a frequency distribution list from this. I don't want to collect the data into ranges (i.e. histogram style) but I do need to know exactly how many instances there are of each value. Values in spreadsheet example below.
https://docs.google.com/spreadsheets/d/10gkP4DLA_k8yrbVdNEFmrDwKrg-B_t6BUkAmPNE2CpQ/edit#gid=0
I don't need the data presented in a graph but if a graph is the easiest way to collate this then that's fine as I will need to routinely do this calculation.
Many thanks.
db
A 'group by' query should do this:
=query(B3:B,"select B,count(B) where B is not null group by B label B 'Value'")

How to display the values in another sheet in descending order using v look up

Please help me to find a solution which am trying to sort out. my query is i want to display the values in another sheet using v lookup formula in descending order.
I may have an answer that works for you.
Look at Sheet1-GK in your sample worksheet.
The formula I used is:
=vlookup(B2, filter('Price History'!A$2:B$18,'Price History'!A$2:A$18=B2),2,1)
Let me know if you need more. I haven't tried to see if this can be made into an arrayformula, so it doesn't need to be copied down.

How to get last item from array (reverse array) Google Spreadsheets

I am using the FILTER formula to get filtered data
=FILTER(A:H,REGEXMATCH(D:D,"......"))
This function returns multiple results from top to bottom of my document.
I need to get the last result from filter function.
How can I achieve this?
I have already tried to transpose, reverse array, etc. But didn't get desired result.
I would be grateful for any help with this matter.
In addition to the contribution of ttarchala, maybe this will also work
=INDEX(A:H,MATCH(2,IF(regexmatch(D:D, "..."),1),1))
=index(
filter(<your_range>, <your_condition>),
rows(filter(<your_range>, <your_condition>))
)
The disadvantage is that you have to repeat the filter parameters twice, maybe someone can improve on this answer?

Resources