Return multiple index Google sheet - google-sheets

This is my query to the espn site for football data when I run the below code this returns only the first column not the full datatable
=IMPORTHTML("https://www.espn.in/soccer/table/_/league/eng.1","table",1)
When I run this =IMPORTHTML("https://www.espn.in/soccer/table/_/league/eng.1","table",2) it returns the datatable but it omits the first column which contains rowname.
Any suggestion how to include both of them?

You can use
=ArrayFormula(
{REGEXREPLACE(IMPORTHTML("https://www.espn.in/soccer/table/_/league/eng.1","table",1),"^\d{1,2}\D{3}",""),
IMPORTHTML("https://www.espn.in/soccer/table/_/league/eng.1","table",2)})
Functions used:
ArrayFormula
REGEXREPLACE
IMPORTHTML

Related

Reverse Partial Match in Google Sheets

I have tried to do the following reverse partial match lookup however this doesn't work in google sheets. Is there another method that will work there?
https://www.excelcampus.com/tips/reverse-partial-match-lookup-filter/
Try the following formula for result including blank cells
=INDEX(IFERROR(REGEXEXTRACT(A2:A,JOIN("|",F2:F7))))
or this one to exclude blanks
=QUERY(INDEX(IFERROR(REGEXEXTRACT(A2:A499,JOIN("|",F2:F7)))),
"where Col1<>'' ",0)
Functions used:
QUERY
INDEX
IFERROR
REGEXEXTRACT3098244

Google Sheets importxml query to remove one piece of data

I'm using the following query in my sheet to import total Spotify streams for artists. Example:
=IMPORTXML("https://chartmasters.org/spotify-streaming-numbers-tool/?artist_name=&artist_id=1uh2pZRWuOebEoQgFVKK7l&displayView=Disco","//tr[#class='careerTotals'][2]")
However it's returning one extra value I don't want ("EAS"). I would like to just have the artist name in A and the total streams in B. Any ideas? Thanks.
How about these modifications?
Modified formula:
=TRANSPOSE(IMPORTXML(A1,"//tr[#class='careerTotals'][2]/td[position()<3]"))
or
=QUERY(IMPORTXML(A1,"//tr[#class='careerTotals'][2]"),"SELECT Col1,Col2")
The URL of https://chartmasters.org/spotify-streaming-numbers-tool/?artist_name=&artist_id=1uh2pZRWuOebEoQgFVKK7l&displayView=Disco is put in the cell "A1".
At 1st modified script, the expected values are retrieved with xpath of //tr[#class='careerTotals'][2]/td[position()<3] and those are put to the columns using TRANSPOSE.
At 2nd modified script, the expected values are retrieved from the retrieved 3 values using QUERY.
Result:
This result is from the 1st modified formula. 2nd one is also the same result.
References:
TRANSPOSE
QUERY

Google Sheets equivalent for Excel's AGGREGAT formula

I am using Google Sheets and I need to implement following excel formula into my sheet.
https://docs.google.com/spreadsheets/d/1XzAYEezt2gNt_tdbxyZT-p6XwjNdhvUbt_9rBoABlhI/edit?usp=sharing
=IFERROR(INDEX(Formularantworten!B:B;AGGREGAT(15;6;ROW(Formularantworten!$B$2:$B$100)/(Formularantworten!$B$2:$B$100<>"")/(Formularantworten!$H$2:$H$100<>"");ROW(A1)));"")
Well if you want to match two columns and index a third column, finding the first match, you can do what you used to do in Excel before Aggregate came along:
=index(C:C,match(1,(A:A<>"")*(B:B<>""),0))
or
=index(C:C,min(if((A:A<>"")*(B:B<>""),row(A:A))))
But in Google sheets you have more options and are more likely to use something like
=query(A:C,"select C where A is not null and B is not null limit 1")

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")

How to use Sumif using range from a complete different Googlesheet/doc

I know how sumif works when I need to access it within the same Google "workbook" (using the analogy from excel). By workbook I mean a collection of sheets, not sure whether there is a different way to refer to Google workbook.
For example in the sheet (Example 3): https://docs.google.com/spreadsheets/d/1Dm-N-1X38zHartE3JbPUtWDnYwEpkGHl6v06huvjSa8/edit#gid=0
I have Sheet2, with column A contain strings and column B containing numerical value. On sheet 1, I have a sumif function which can be query data stored in Sheet2, and sum the cells which match A1 in Sheet1.
The problem starts happening when I try to refer to ranges in a completely different workbook, which is shown below.
I am trying to do a sumif over 2 ranges from a different "workbook". The data is stored here (Example 2): https://docs.google.com/spreadsheets/d/1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0/edit#gid=0
The Sumif function is in Cell B1 of the following sheet (Example 1):https://docs.google.com/spreadsheets/d/1AitilELd6w7Dbv9d-mKhBYGTBaO6DdkU29Y5mofX2TI/edit#gid=0.
From my understanding importrange is typically used to refer to ranges in completely different workbooks, as a result I use importrange as the first and last arguments in the sumif function in the Sheet Example 1.
What am I doing wrong? Why is this not working?
Can anybody help?
Thanks a lot
See if this query does what you want:
=SUM(query( QUERY( Importrange("1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0","Sheet1!A1:B10") ) , "select Col2 where Col1 contains '"&A1&"'" ) )

Resources