Link to view-only sheet.Looking to find the cheapest flight plan between two points. There’s additional information on the sheet.
Available flights are of the form:
From
To
Price
Airport1
Airport2
100$
Airport2
Airport3
500$
Sample data with an intended output can be found on the sheet.
try:
=QUERY(SORTN(QUERY(SORT(A2:C6, 1, 1, 2, 1, 3, 1),
"where Col1<Col2", ), 9^9, 2, 1, 1),
"where Col1 >="&F1&" and Col2 <="&F2, )
Related
In the below spreadsheet, I am trying to find the item with the highest total sales across various hours.
I would like to easily extract the highest and lowest selling item names as well as their corresponding total sales. I need to be able to do this without creating a helper column as I cannot edit the table.
I know there's probably an easy way to do this but for the life of me I cannot figure it out!
Link to Sheet
B12:
=INDEX(SORT(SPLIT(FLATTEN(B2:G10&"×"&A2:A10&"×"&B1:G1), "×"), 1, 0), 1, 2)
B13:
=INDEX(SORT(SPLIT(FLATTEN(B2:G10&"×"&A2:A10&"×"&B1:G1), "×"), 1, 0), 1, 1)
B14:
=INDEX(SORT(SPLIT(FLATTEN(B2:G10&"×"&A2:A10&"×"&B1:G1), "×"), 1, 1), 1, 2)
B15:
=INDEX(SORT(SPLIT(FLATTEN(B2:G10&"×"&A2:A10&"×"&B1:G1), "×"), 1, 1), 1, 1)
** edit: use player0's for the overall min and max.
Check this demo sheet
To get the highest or lowest by time slot (put this in I5),
=ARRAYFORMULA(
IFERROR(
VLOOKUP(
TRANSPOSE(B1:G1),
SORT(
SPLIT(
FLATTEN(B1:G1&"|"&A2:A&"|"&B2:G),
"|"),
3,FALSE),
{1,2,3},FALSE)))
Then to align the lowest per timeslot with that, put this in M5
=ARRAYFORMULA(
IF(ISBLANK(I5:I),,
IFERROR(
VLOOKUP(
I5:I,
SORT(
SPLIT(
FLATTEN(B1:G1&"|"&A2:A&"|"&B2:G),
"|"),
3,FALSE),
{2,3},FALSE))))
If you also wanted conditional formatting for the daily high and low, use a range of B2:G with
=AND(LEN(B2),MIN($B2:$G2)=B2)
If you really want to have these formulas below the table, change
FLATTEN(B1:G1&"|"&A2:A&"|"&B2:G),
to
FLATTEN(B1:G1&"|"&A2:A10&"|"&B2:G10),
Background Information
I am trying to setup a 1st, 2nd and 3rd rank/scoring system on Google Sheets. The sheet is setup by row and once a week a new row is added.
1. On the left-hand side of each row there are six columns. The top of each column is a cell that contains the value identifier for that column (such as a person's name or ID#). Each week the score is entered into each column.
2. The right-hand side of each row is to identify the 1st, 2nd and 3rd place winners. This area also contains six columns with the headers 1st, 2nd, 3rd. I'm trying to set it up so that each week when the new numbers are added to the next row, the relevant score is shown and the cell next to it shows the name/ID associated with that week's score. Then repeat for 2nd and 3rd.
Problem
Everything works perfectly; unless there is a tie. In that situation the information is duplicated because it stalls on the first match. I have attempted various things, including using "RANK()" and a helper column to eliminate duplicate scores, but as of yet this has me stumped. How can this be solved?
To illustrate what I am trying to do, I have an editable example sheet here:
https://docs.google.com/spreadsheets/d/1bmt77kQOtCu8OybNrWH48XKjBKD_HEZ_B6TqweZKEAI/edit?usp=sharing
use in J6:
=ARRAYFORMULA(ARRAY_CONSTRAIN(SORTN(SORT(SPLIT(
FLATTEN(D6:I*1&"×"&D5:I5&"×"&ROW(D6:D)), "×"),
3, 1, 1, 0), 9^9, 2, 3, 1), COUNTA(B6:B), 2))
in L6:
=ARRAYFORMULA(ARRAY_CONSTRAIN(SORTN(QUERY(QUERY(SORT(SPLIT(
FLATTEN(D6:I*1&"×"&D5:I5&"×"&ROW(D6:D)), "×"), 3, 1, 1, 0), "offset 1", ),
"skipping "&COUNTA(D5:I5), ), 9^9, 2, 3, 1), COUNTA(B6:B), 2))
in N6:
=ARRAYFORMULA(ARRAY_CONSTRAIN(SORTN(QUERY(QUERY(SORT(SPLIT(
FLATTEN(D6:I*1&"×"&D5:I5&"×"&ROW(D6:D)), "×"), 3, 1, 1, 0), "offset 2", ),
"skipping "&COUNTA(D5:I5), ), 9^9, 2, 3, 1), COUNTA(B6:B), 2))
Is there anyway in which I can first sort the data date wise and then remove the duplicate names for the same day.
try:
=ARRAY_CONSTRAIN(SORTN({A2:C, B2:B&A2:A}, 9^9, 2, 4, 0, 2, 1), 9^9, 3)
I'm trying to build a very simple inventory sheet. Apologies in advance, but I'm very new at this.
a) I'd like my inventory sheet to show stock for individual items, and for kits (BOMs)
b) I'd also like the array formula to update depending on an adjacent column value (i.e. if the row shows 'fulfilled' then the array should ignore it.
I have been able to modify an old post that I found here, but unfortunately the original document was modified. https://support.google.com/docs/thread/23230245?hl=en
Does anyone have access to that original doc? I know Matt King was involved.
Does anyone know of a beginner's guide to Google Sheets Query / Array formulas?
I know I'm speaking in gibberish, but believe me I'm fascinated with this and I'm a quick learner. Would also be interested in paid coaching if anyone's into that!
https://docs.google.com/spreadsheets/d/1btnxxI00qI9njIUzudAZXh4G87TWcHoWtfPl4jBl7jM/edit?usp=sharing
={"Units"; ArrayFormula(IFNA(VLOOKUP(B2:B, QUERY({'BOM Import'!F2:I},
"select Col1,sum(Col4)
where Col4 is not null
group by Col1
label sum(Col4)''"), 2, 0)))}
={"Total Stock on Hand"; ArrayFormula(IF("yes"=IFNA(VLOOKUP(IFNA(VLOOKUP(B2:B, {'BOM Import'!F2:F, 'BOM Import'!E2:E}, 2, 0)), SORTN(SORT({'Kits Requested'!B2:B, 'Kits Requested'!A2:D}, 2, 0), 9^9, 2, 3, 1), 5, 0)), 0,
IFNA(VLOOKUP(B2:B, QUERY({'BOM Import'!F2:J}, "select Col1,sum(Col5) where Col5 is not null group by Col1 label sum(Col5)''"), 2, 0))))}
select sum(Col1),sum(Col2),sum(Col3) ... up to 500 columns but the number might increase or decrease... what is the best way to go about this with one formula?
it would be really nice if you could just do select sum(*) ... but sadly that does not seem to work.
you can do:
=ARRAYFORMULA(QUERY({A1:SF}, "select "&TEXTJOIN(",", 1, "sum(Col"&ROW(A1:A500)&")")))
or:
=ARRAYFORMULA(QUERY({A1:SF}, "select "&TEXTJOIN(",", 1, "sum(Col"&COLUMN(A1:SF)&")")))
or infinitely expanding:
=ARRAYFORMULA(QUERY({INDIRECT("A1:"&SUBSTITUTE(ADDRESS(1, COLUMNS(1:1), 4), 1, ))},
"select "&TEXTJOIN(",", 1, "sum(Col"&ROW(INDIRECT("A1:A"&COLUMNS(1:1)))&")")))