Index & Match function giving duplicated value - google-sheets

Hi, I'm trying to match the names to the numbers.
I got the C7:C11 using the SORT(TRANSPOSE(B3:F3,2,FALSE)
Using INDEX() and MATCH() at B7:B11, I want to get the names that reflect the numbers but its showing me duplicated returns. As there is 2 of "2", the name reflected will show up as "B" twice.
The index and match function I'm using :
=INDEX($B$1:$F$1,MATCH(C7,$B$3:$F$3,0))
I'm fairly new to this so I've no idea how to go about doing this.

Try this way in Google Sheets, it should work,
• Formula used in cell D7
=INDEX(FILTER($B$1:$F$1,C7=$B$3:$F$3),COUNTIF($C$7:C7,C7))
And if you are using in Excel then either of the ways based on Excel Version
• Formula used in cell D7 --> Applicable to Excel 2021/MS365
=INDEX(FILTER($B$1:$F$1,$C7=$B$3:$F$3),COUNTIF($C$7:C7,C7))
• Formula used in cell E7 --> Applicable to All Excel Versions Except Excel 2007
=INDEX($B$1:$F$1,AGGREGATE(15,6,(COLUMN($B$3:$F$3)-COLUMN($B$3)+1)/($C7=$B$3:$F$3),COUNTIF($C$7:C7,C7)))
As an alternative for Excel, version dependent as suggested by JvdV Sir,
=TOCOL(SORTBY(B1:F1,B3:F3))
Or,
=TRANSPOSE(SORTBY(B1:F1,B3:F3))
Or, in Google sheets, with QUERY() Function
=QUERY(TRANSPOSE(B1:F3),"Select Col3, Col1 Order By Col3")

Related

Why can't my Google Sheets Query recognize formula results as numbers?

So I have a formula one one sheet that calculates the difference between the current date (Using the today function) that corresponds to when a repair was requested - this column gives me how many days have passed since the request was made. In a separate sheet, I want to query the requests that are beyond 14 days old but less than 22 days. I write the query as:
Select A,B,C,D,G Where J>14 and J<22
but the cell just displays "N/A". But if I rewrite the code with single quotes on the 14 and 22 as:
Select A,B,C,D,G Where J>'14' and J<'22'
It returns repair requests that are two days old. This tells me that it recognizes the formula results as Strings even if I already set the format to Number.
Can anyone help?
To anyone wondering, I was able to fix this issue by using the VALUE() function (which works for both Google Sheets and MS Excel) which converts any string to numbers.
if J column are dates try:
=INDEX(QUERY({A:G, DAY(J:J)}
"select Col1,Col2,Col3,Col4,Col7
where Col8 > 14
and Col8 < 22")

Dynamically changing Reference for Query funciton on Google Sheets

I've got a Spreadsheet where on the sheet "Dados de Cadastro e Resumo" on column K (from roll 7 to 29) I'm using the formula =IF(J7="";"";SUM(QUERY({Caminhoneiro!G:I;Centralizado!G:I;Djoko!G:I};"Select Col2 where Col1 = '"&J7&"'";))) to sum up the hours from the sheets "Caminhoneiro","Djoko" and "Centrealizado".
The thing is, I want to make it so I don't have to edit the formula every time to accommodate for new sheets. My ideia was to use the names on column E (from roll 7 to 29) and make the reference for the Query based on that.
So far I've got the string done (on M6), but haven't been successful on turning that on to a valid array reference (using INDIRECT, which I later learned doesn't deal with multiple intervals.

How to use absolute references in google sheets query formula or query by column names for multiple sheets?

I have the following problem. I'm trying to write query formula in order to put all values in one sheet by typing yes in one column, however, I have the following problem. Whenever I add a new column, references in query formula (multiple sheets) are changing and the formula doesn't work. How can I prevent this?
Or is there any way to query by a column name in multiple sheets?
I have tried locking relative references by putting sign $
I have tried to use an indirect formula to take references (data set in Helper TAB, cell E2) - nothing worked
I'm out of the ideas, for now, anyone knows how to fix this?
=QUERY({'Sheet 1'!$A:$Z;'Sheet 2'!$A:$Z;'Sheet 3'!$A:$Z;'Sheet 4'!$A:$Z}, "select * where Col1 ='yes'",0)
Here is the file I did, you can see query formula in Master sheet:
https://docs.google.com/spreadsheets/d/1XD-CECy5W5-HM5EkBFJQKDtLlykQq8Cj8ZOvDUXkd1s/edit?usp=sharing
A solution to the problem is to use a formula that searches for the column address based on a reference.
=SUBSTITUTE(ADDRESS(1;COLUMN(A1);4);"1";"")
This formula will return the value A, which is the column of address A1.
It can be used in query functions like this:
=QUERY(A:D;"SELECT "&SUBSTITUTE(ADDRESS(1;COLUMN(A1);4);"1";"")&"")
This function is equivalent to the function:
=QUERY(A:D;"SELECT A")

external range in sumif formula in google spreadsheet

in a google spreadsheet I want to use the formula SUMIF;
the syntax of function is SUMIF(A1:A10,"Paid",B1:B10)
as first parameter (and last) I want use a range of another google sheet;
I used the function IMPORTRANGE but the result is always #N/A
my code is:
sumif(importrange("xxhEwtMr2xxzRmiucxRgA5P119SEmsqL2R08gggt4Yyg", "list!$E:$E"),$S7,importrange("xxhEwtMr2xxzRmiucxRgA5P119SEmsqL2R08gggt4Yyg","list!$C:$C"))
where am I wrong?
ps.
the error pop-up report:
Error
Argument must be a range.
My understanding is that the third argument in the SUMIF must be a direct reference to the local worksheet.
You can either add an additional tab to import the data into, or try a different formula approach such as:
=SUM(QUERY(importrange("xxhEwtMr2xxzRmiucxRgA5P119SEmsqL2R08gggt4Yyg", "list!$C:$E"),"select Col1 where Col3 = '"&$S7&"'",0))
You could make an easier work around is to use the import range to a new sheet.
Then sumif it from that sheet. It will still dynamically update.

Using a formula to specify sheet in Google Spreadsheets

What I did is pseudocode basically and I just want to specify the sheet using a cell as shown in the picture. What is the proper notation (if there is any)?
(Trying to solve E3 in this example. It should show a number from another sheet, and I just want to make it easy to copy/paste down column E by referencing to the sheets using the strings in column A)
You can use INDIRECT() function to do that, for example :
=INDIRECT(A3 & "!B4")
You may need to wrap sheet name with quotes if it contains special character(s) :
=INDIRECT("'" & A3 & "'!B4")

Resources