In my spreadsheet using array formula I am creating a unique list of values based on multiple conditions. Formula is below:
{=INDEX(INDIRECT($O$3&"!$L$2:$L$"&$O$16),SMALL(IF((INDIRECT($I$3,FALSE)=$O$7)*(INDIRECT($K$3,FALSE)=$O$9)*(INDIRECT($M$3,FALSE)=$O$11)*(INDIRECT($X$17,FALSE)=$O$15)*(INDIRECT($AF$17,FALSE)>$O$15),ROW(INDIRECT($O$3&"!$L$2:$L$"&$O$16))-2,""),ROW()-20))}
Question belongs to this part if IF function:
(INDIRECT($K$3,FALSE)=$O$9)
Cell $O$9 contains drop down which includes one of cell content variables as well as <>, <>*, <> * Text*,""
When I use direct text match: specific column contains list of fruits and "apple" is one of the values, once $O$9 contains word "apple" formula works and I get a unique list. Should $O$9 contain any of above mentioned combinations (<>, <>*, <> * Text*,"") it gives me an error.
Question: How to change "=$O$9" so that it will be able to use following content of the $O$9 equals to <>, <>*, <> * Text*,"", etc.
Note: I cannot adjust drop down in cell $O$9 but can modify array formula only.
Thanks in advance!
Well this is by no means a complete answer but just to show my thinking:-
Suppose you have two column ranges which I have called AA and BB and you want to implement some of your tests based on $O$9. It would look something like this:-
=SUM((BB=1)*IF($O$9="<>",AA<>"",IF($O$9="<>*",AA="",IF(ISNUMBER(FIND("*",$O$9)),ISERROR(FIND(MID($O$9,4,LEN($O$9)-1),AA)),$O$9=AA))))
So what I am saying is that your (INDIRECT($K$3,FALSE)=$O$9) would have to become something like the contents of the brackets following SUM above.
Related
i'm trying to create a dropdown list that return the values of a big table if a certain criteria is true:
For example, in this example I need the dropdown to list all the names which city is "Bilbao".
If I create a sheet that "lists" all the posible dropdowns (one for each city with the names listed below), there's no problem. But I'm trying to don't use that sheet, I mean, that the dropdown directly calculates the correct list as an array and show it. That's because the real workbook has more than 100 "cities" that can change at any time.
Is it possible or maybe i'm overcomplicating that?
Regards!
You'll need to use a range that your filtered list of values appear in.
The formula =FILTER(Sheet1!$A$2:$A$11,Sheet1!$B$2:$B$11=Sheet1!$D$2) will return just those names that appear in the city shown in D2.
To use it in your data validation add a named range to the Name Manager (Formulas > Name Manager). My formula is in cell G2, so my named range looks at =Sheet1!$G$2# and is named CityFilter.
Now create your Data Validation to look at CityFilter.
Link to example file:
https://docs.google.com/spreadsheets/d/1dCQSHWjndejkyyw-chJkBjfHgzEGYoRdXmPTNKu7ykg/edit?usp=sharing
The tab "Source data" contains the data to be used in the query on the tab "Query output". The tab "Desired result" shows what I would like the end result to look like.
The goal I'm trying to achieve is to have the formula in cell A2 on the tab "Query output" to populate the data in all four of the columns, so that it looks exactly like the "Desired result" tab. I know I can get the same result simply by entering additional formulas in C2 and D2, but this is not the objective, I need the results to come specifically from the single formula in A2.
The information in the "Additional data 1" column should simply repeat the word "Test" for every row that contains data in the first two columns. The information in the "Additional data 2" column should simply repeat the data from cell 'Source data'!A1 for every row that contains data in the first two columns.
Please feel free to edit the example file as it only contains dummy data. If you like, you can copy the tab "Query output" to create your own working formula for illustrative purposes.
EDIT:
I'm thinking along the lines of creating an array that consists of the required data for the columns "Additional data 1" and "Additional data 2" and then combining that array with the array of the query result which provides the first two columns. I've been experimenting with this in various ways, but so far the only result I have achieved is an error on the first cell of the query results. I also have no idea yet how I could make sure that the second array contains an equal amount of rows to the query result.
You can add static data into query:
=QUERY('Source data'!A3:B,"SELECT A,B, 'Test', '" & 'Source data'!A1 &"' WHERE A IS NOT NULL LABEL A '', B '', 'Test' '', '" & 'Source data'!A1 &"' ''")
Many thanks to #basic for the provided assistance! The insights were a great help to solving my issue. That said, I have muddled along a bit, and I've come up with a slightly different solution which I find better suited as it gives true blank values instead of a column filled with spaces.
First of all, instead of querying directly on the source data, I built an array and queried on that. I used the two existing columns (A and B) from the source data and added a third column to the array which does not exist in the source data. In order to make sure that the third column would consist of blank values, I used the IFERROR formula.
=IFERROR(0/0)
The formula above returns a blank because dividing by zero forces an error and the IFERROR method returns a blank unless an alternative return value is specified.
In order to be able to use this formula in an array however, it had to be tweaked slightly, because as it is it would only return a single blank cell value instead of a column of blank values. To do this, I used an already existing column from the source data, and then encapsulated it in an ARRAYFORMULA.
=ARRAYFORMULA(IFERROR('Source data'!A3:A/0))
Using this, the resulting array has the following formula.
=ARRAYFORMULA({'Source data'!A3:A,'Source data'!B3:B,IFERROR('Source data'!A3:A/0)})
This creates an array consisting of the two original columns A and B from the source data, plus an additional third column filled with blank values. This array can now be queried upon, and using the tricks previously provided by #basic the desired result as specified in the original question can be achieved.
Due to the query now being used upon a user-defined array, the columns in the SELECT statement now have to be referred to as Col1, Col2, Col3, instead of A, B, C. The final formula now looks like this.
=QUERY(ARRAYFORMULA({'Source data'!A3:A,'Source data'!B3:B,IFERROR('Source data'!A3:A/0)}),"SELECT Col1,Col2,'Test',Col3,'"&'Source data'!A1&"' WHERE Col1 IS NOT NULL LABEL 'Test' '','"&'Source data'!A1&"' ''")
I hope this information may prove of use to someone else as well.
My Google Sheet that will be updated over time with new sheets. On my dashboard/master sheet, I can write a simple INDIRECT that will pull information from a cell in the sheets. However, the formula does not replicate its way down the column. I understand that I need to use an ARRAYFORMULA to get the auto formula placement done.
I've tried many ways but the one that I think may get me there is to use CONCAT. My columns look like this:
Event Title [uses a script to pull in the names of all the sheets]
Use an array to get the titles so they pre-poluate down the column so I can use it later: =ARRAYFORMULA(IF(Row(A:A)=1,"Get Title from A",IF(ISBLANK(A:A),"",A:A)))
-- The Event Title is now appearing as plain text in Column B.
I then use CONCAT to write the part of the formula I need to help get the name of the INDIRECT in without using the INDIRECT formula.
=CONCAT("'"&B5&"'"&CHAR(38)&"!"&"""","B2"&"""")
-- This gets me this result: 'Computers 101'&"B2"
At this point, my hope is that I could then use this information ('Computers 101'&"B2") into an ARRAYFORMULA. I used this formula to try and do that:
={"Event Date";ARRAYFORMULA(A6:A+D6:D&"Cat")}
-- I get the answer: 0
The expected value was the date cell (B2) in the Computers 101 sheet. Any ideas how to proceed? I don't know the names of the sheets in advance.
unfortunately, this is not possible within of scope of google sheets formula. if you need ranges from other than the actual sheet you need to use INDIRECT which is not supported under ARRAYFORMULA.
you have 3 options:
hardcode it like: https://stackoverflow.com/a/68446758/5632629 with IFERROR & array of empty cells to match columns of your range
generate formula which will generate your final formula/range as a text string and then use a simple script to convert that string into the valid formula: https://stackoverflow.com/a/61819704/5632629
do it all with scripts
I am trying to make an excel template so that when a user copies data into the tab "Account Profile", the last row with contents in it is calculated and this value is used for formulas on other sheets. This formula calculates the last row with data:
=LOOKUP(2,1/('Account Data'!A:A<>""),ROW('Account Data'!A:A))
This works fine, the trouble comes when I try to use the result as a range reference: I want my formulas to iterate from row 2 --> row (value of LOOKUP)
=COUNTIF('Account Data'!$N$2:$N$991,A8)
The "991", I want that replaced with the result of the LOOKUP formula so that the range is always correct. I'm sure there's an easy way but I've tried for a while and can't figure out what the syntax should be.
Scott is right that you should just be using COUNTIF directly with a column reference. However, in case this is a contrived example or something, this is how you'd do it the way you described:
=COUNTIF(INDIRECT("'Account Data'!$N$2:$N$" & LOOKUP(2,1/('Account Data'!A:A<>""), ROW('Account Data'!A:A))), A8)
The important part to look at is INDIRECT("'Account Data'!$N$2:$N$" & LAST_ROW_NUMBER). The INDIRECT function is how you take a string of text and interpret it as a cell reference. The "Some text" & VARIABLE_NAME is how you build such a text string from variables: you use the & symbol to concatenate them.
COUNTIF is not an array formula and as such you can use full column references without detriment.
=COUNTIF('Account Data'!$N:$N,A8)
But if you really want a dynamic range then use INDEX/MATCH:
=COUNTIF('Account Data'!N2:INDEX('Account Data'!N:N,MATCH(1E+99,'Account Data'!A:A)),A8)
This will find the last cell in column A that has a number. If Column A is filled with text then replace 1E+99 with "ZZZ".
If you want to use LOOKUP then:
=COUNTIF('Account Data'!N2:INDEX('Account Data'!N:N,LOOKUP(2,1/('Account Data'!A:A<>""),ROW('Account Data'!A:A))),A8)
I want to conditionally grab lines from a database-style spreadsheet in Google Spreadsheets (a list with a name, location, description, price) after checking the value with a vlookup - I've used this a while ago and expected it to CONTINUE an array across for the other columns next to the one 'looked up', but it seems my memory fails me here and it just retrieves the 'searched out' value.
=vlookup("Yes",'All 2014-15'!A2:G,2)
This formula basically finds the first value of the desired rows and should create a 'Selected items from 2014-15' list, but I can't work out how to expand it to produce a list of all the rows I want. Is there a simple way to retrieve this, I've tried playing with arrayformula but no success.
I can change the index simply to get the other values across, but if this could be filled out through an array too that would be preferable...?
Can you try this...
=FILTER('All 2014-15'!A2:G,'All 2014-15'!A2:A="Yes")
Edit:
As suggested by Immx, added apostrophes to sheet name and the second range changed to A2:G to A2:A assuming the yes/no data is in A column.