Add value to cell if condition is meet

iMSn20

I have a sheet with columns and rows like this example:

|   COLOUR   |   TO COLOR   |   DONE   |
 Red          Green          YES
 Blue         Yellow         YES 
 Yellow       Red            YES
 Blue         Green          NO

And another one with this structure:

|   COLOUR   |   OUT   |   IN    |

What I want to do, on the second sheet, every time a row is generated in the first sheet, I want to calculate for every colour how many went out and how many went in.

So, with that example, the second sheet looks like this:

|   COLOUR   |   OUT   |   IN    |  
 Red          1         1
 Blue         1         0
 Yellow       1         1

This is what happend:

  1. Row 1: it was red and turn green so in the second sheet, in the row of red I need to add 1 to OUT
  2. Row 2: it was blue and turn yellow so in the second sheet, in the row of blue I need to add 1 to OUT
  3. Row 3: it was yellow and turn red so in the second sheet, in the row of yellow I need to add 1 to OUT and in the row of red I need to add 1 to IN

This happend with the rows who in the column of DONE is YES. For example, the fourth row is NO so I don't need to calculate this row.

How I can do this? I was trying with IF but I don't know how to use formulas in Google-Sheets.

player0

try:

=ARRAYFORMULA(QUERY(IFERROR(SPLIT(FLATTEN(IF('Hoja 1'!C2:C="yes"; 
 {'Hoja 1'!A2:A&"×1×IN"\'Hoja 1'!B2:B&"×1×OUT"}; )); "×")); 
 "select Col1,count(Col2) where Col2 is not null group by Col1 
  pivot Col3 label Col1'COLOUR'"))

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Changing value if they meet a condition, dataframe

For each cell in range, add cell value to array-- IF condition is met

masking specific cell values in rows that meet condition

if previous value in one column and next value in another column meet a condition, add 1 into another column using r

Add new line into the Excel Table if Condition meet

How to add the condition if a cell value is not an email address in Google App Scripts

Extract value from struct that meet condition

Impute value cell with condition

Modify large cell array to find certain rows that meet a condition in MATLAB

In a table, function to get all cell values that meet condition in a different column

Add html attribute if the input value meet requirements

Add formula containing condition to cell

Repeat the cell value in dataframe by condition

How to add or combine two columns into another one in a dataframe if they meet a condition

Add new rows for rows that meet a specific condition in a dataframe

Python - add a timestamp column if meet condition in csv file

Add column that sums all previous rows that meet condition

how to add a value to cell

Add value to cell in a loop

Select value of one column if a separate column does not meet a certain condition

Keeping one value even if same condition is meet again

filter on a value in a column and remove rows that dont meet condition

Update row value only when all other rows meet the condition

Add a condition with alias value

How to copy cell from Sheet 1 to Sheet 2 (in certain sequential) if condition in Sheet 1 is meet

How to add a if condition in a function in a table cell in yii?

Add multiple condition in one cell in Excel

Add a Value Automatically to a Cell Based on Another Cell

How to meet properly if condition