google spreadsheets: compare two cells and pull out different words - google-sheets

I have two cells that contain the concatenated column values separated by the | symbol. I want, without using a script, write a formula that compares these two cells and shows different words. Words that were used in A2 cell, but were not used in A1.
For example:
in cell A1 I have
test1 | banana | test2 | cat,
and in A2 cell i have
test1 | pineapple | test2 | dog.
The result of the formula should be something like
pineapple | dog
Is it possible?

=ArrayFormula(QUERY(TRANSPOSE({SPLIT(A2," | ");COUNTIF(SPLIT(A1," | "),SPLIT(A2," | "))}),"select Col1 where Col2=0",0))

try:
=TRIM(JOIN("|"; FILTER(SPLIT(A2; "|");
NOT(COUNTIF(SPLIT(A2; "|"); SPLIT(A1; "|"))))))

Related

Convert a list of rownumbers to a list of cells and apply a formula to them in Google Sheets

I have a list of numbers in Column B corresponding to different rownumbers in Column A (for example, in B1, I have the list {1,2,3}).
I would like to turn this list into a list of cells ({A1,A2,A3}) and apply a formula to that list in Column C (for example, I would like to AND them together).
Column A always contains Boolean Values.
Column B will always contain valid rownumbers separated by a comma.
I would like a formula that I can put in Column C and drag down and extract the numbers from (for example using =SPLIT(B1,",")) and then apply a formula to.
Shown in the table below is a sample of what I would like to achieve. Note that Column C contains a manual entry approach that I would like to avoid.
| Column A | Column B | Column C | Column D (expected ouput)
| -------- | -------- | -------------- | -----------
Row 1 | TRUE | 1,2,3 | =AND(A1,A2,A3) | FALSE
Row 2 | FALSE | 2,4 | | FALSE
Row 3 | FALSE | 4,6,2,1 | | FALSE
Row 4 | FALSE | 2 | | FALSE
Row 5 | TRUE | 1,5 | | TRUE
Row 6 | FALSE | 1,5,3 | | FALSE
Some things I have tried include using
=INDEX(A:A,SPLIT(B1,","),1)
=AND(ARRAYFORMULA(INDEX(A:A,SPLIT(B1,","),1)))
I have also tried moving around the order of the formulas in the above equation to no avail.
I have only managed to get my formula to be affected by the first rownumber in column B.
You were very close! With BYCOL (considering that the SPLIT result is a serie of cells in columns) you can get the INDEX of column A; and wrap it in AND:
=AND(BYCOL(SPLIT(B1,","),LAMBDA(i,INDEX(A:A,i))
If you want, you can wrap it in BYROW to apply to your whole range:
=BYROW(B:B,LAMBDA(b,IF(b="","",AND(BYCOL(SPLIT(b,","),LAMBDA(i,INDEX(A:A,i)))))))

Reference range when column matches string

Budget spreadsheet. Column A contains categories, Row 1 contains paycheck dates, and each cell from B2:AE91 contains numeric values ("how much I spent on categoryX during paycheckY").
Named ranges:
Column A - "Budget_LineItem"
Row 1 - "Budget_PayPeriods"
On another tab, I have a list of specific categories called "Funds," where I want to track how much I've saved so far each paycheck toward the category by adding up the category's values each paycheck up until TODAY().
For example:
| | A | B | C | D |
| - | - | - | - | - |
| 1 | Fund | Balance | Today: | =TODAY() |
| 2 | Auto Insurance | =SUMIF(Budget_PayPeriods,"<="&MAX($D$1:$D$2),Budget!F48:AE48) | Projected Date: | |
As you can see, I just have a static range for the "Auto Insurance" category: Budget!B48:AE48. This works, but I want a formula that looks up the adjacent value in column A against the Budget_LineItem range, and returns the row range from B:AE in the Budget spreadsheet.
Basically reads: "Go find how much I've saved/spent so far toward categoryX in the Budget tab, and add up all the values for each paycheck up through today."
I know I'm close, but I can't make INDEX, MATCH, or any of the LOOKUP functions do what I need. I just can't figure it out.
EDIT: Here's a link to an example: https://docs.google.com/spreadsheets/d/1L4mlMrRCWwDNPSiYHpmFiXU1zNOnga6gAziz_m2awKI/edit?usp=sharing
I also made a change to the OP formula in B2 as I realized it didn't work. I had tweaked it because my original formula had extra complexity and I was trying to KISS for this question. I changed it back to the more complex version so it works properly now.
delete range B2:B and use this in B2:
=INDEX(MMULT(FILTER(Budget!B2:4, Budget!B1:1<=MAX(D1:D2))*1,
SEQUENCE(SUMPRODUCT((Budget!B1:1<=MAX(D1:D2))))^0))
update:
=INDEX(IFNA(VLOOKUP(A2:A,
{Budget!A2:A4, MMULT(FILTER(Budget!B2:4, Budget!B1:1<=MAX(D1:D2))*1,
SEQUENCE(SUMPRODUCT((Budget!B1:1<=MAX(D1:D2))))^0)}, 2, 0)))

I have a list of strings, and I'd like to call INSERTDATA with multiple rows for each item in my list. How can I do this?

I have a list of names.
| aaa | =insertdata("http://url/api/" & A1) |
| bbb | =insertdata("http://url/api/" & A2) |
| ccc | =insertdata("http://url/api/" & A3) |
The problem is insert data is going to insert more than one row, and I need to offset each insertdata() by the number of rows it returns. I also have thousands of names in my list, so I would like some way to do this automated.
I could always write a script, but I'm wondering if there's a built-in function or other feature that does this.

Get multiple values, selected according to another column, into a single cell

I am trying to find a way to get multiple values from an array to display in one cell
For example I have the two columns as below
| a | 1 |
| b | 2 |
| c | 1 |
| d | 3 |
| e | 2 |
So if the parameter is 2 the cell would display "be"
I want all the values form the first column where the second column is 1.
I have tried to do this with dget but that only returns a single value. Is there a way to do this with formulas or does it require a Javascript solution?
You can do it by using filter to return only the letters next to "2", and then join to join them in one cell.
=join("", filter(A1:A, B1:B = 2))

Trying to loop through all cells that start with the contents of another cell using ARRAYFORMULA and RegExMatch

I have a Google Spreadsheet setup; it's for a product import. I am trying to loop through all rows, when C2:C == "configurable" I want it to join (with a comma) all B2:B cells that start with the contents of B in the current "configurable" row.
For example, the table may look like this.
Name | SKU | Type | Simple Products
Prod 1 | 001 | configurable | 001.01,001.02
Prod 2 | 001.01 | simple |
Prod 3 | 001.02 | simple |
Prod 4 | 002 | configurable | 002.01,002.02,002.03
Prod 5 | 002.01 | simple |
Prod 6 | 002.02 | simple |
Prod 7 | 002.03 | simple |
The "Simple Products" column (D2) is where the formula would be located. It will scan each row, if C* = configurable, then it will use the B* value to find all "simple" SKUs that start with the value in B*.
I have it almost working, using the following formula:
=ARRAYFORMULA(
IF(
C3:C="configurable",
join(
",",
transpose(
iferror(
filter(
B3:B,
C3:C="simple",
RegExMatch(B3:B, B3)
)
)
)
),
""
)
)
However, the above always uses B3 for the RegExMatch, so every configurable row contains 001.01,001.02 rather than the row it is currently outputting data in.
Try:
=ArrayFormula(IF(C2:C="configurable",REGEXREPLACE(TRIM(REGEXEXTRACT(QUERY(B2:B,,ROWS(B2:B))&" ","(?:"&B2:B&"\.[0-9]+ )+"))," ",","),))
Although there's a couple of assumptions made based on your sample data (eg the SKUs are sorted).
The issue with your attempt is that the FILTER function can't iterate down the column.
Credit to Isai Alvarado who came up with the QUERY method of building very large strings; larger than the 50k character limit that is normally imposed.

Resources