Find rows in which the total of certain cells in that row does not equal 5 - excel

So I am getting data fed into a spreadsheet on Google Sheets. I cannot edit that spreadsheet.
I have an additional sheet in the document that totals up the columns in this sheet. The sheet received info such as:
A B C D This info is not actually in the sheet
|------------| \/ \/
| 4 1 0 0 | <-- Valid
| 3 1 1 0 | <-- Valid
| 3 1 0 2 | <-- Invalid
| 3 0 1 1 | <-- Valid
|------------|
The total of each individual row should be 5, but I do not currently have a way of validating this in the form itself. So I need to disregard or remove the data if it is in violation.
Basically, I want to find the first row in which the total of these 4 cells are not 5.

In excel try this Array formula:
=MATCH(1,IF(($A$1:$A$4+$B$1:$B$4+$C$1:$C$4+$D$1:$D$4)<>5,1,0),0)
This needs to be confirmed with Ctrl-Shift-Enter when exiting edit mode.
In google sheets it would simply be:
=ArrayFormula(MATCH(1,IF(($A$1:$A$4+$B$1:$B$4+$C$1:$C$4+$D$1:$D$4)<>5,1,0),0))

Related

Microsoft Excel- Invert a 0/1 value or leave empty if no value

I'm ran into an issue while trying to do some work in an excel doc. I have created a column to count the number of flags in other columns. One of the flags I created simply inverts the value of another flag. I'm aware there's no reason for the new column if all I'm doing is inverting the value of a column that already exists, but space isn't an issue and in this case it's much easier for to create a 2nd column to keep things easier to understand.
The new column I created is based off a "consent given" column where the value is 1 if consent has been given, 0 if it has not been given, or empty if we don't have that information. I want my flag counter to count when consent has NOT been given, but I can't figure out a formula to set the value as 0 if consent has been given, 1 if it has not been given, or empty if no information. I can easily say 1 for no consent and 0 for consent or no information, but I want the no information columns to be empty. I can't use an empty string in the case of no information because that breaks my flag counter sum column.
Here is some example data of how I would like everything to be-
A | B | C | D
-------------------------------------------------------------
flag counter | consent given | consent not given | other flag
-------------------------------------------------------------
0 | 1 | 0 | 0
1 | 1 | 0 | 1
1 | 0 | 1 | 0
2 | 0 | 1 | 1
1 | | | 1
0 | | | 0
Formulas I am currently using (all formulas only look at cells in their same row- i.e. A1 uses B1, C1, D1, while A2 uses B2, C2, D2. I'll list A1 below for simplicity):
A1: =C1+D1
B1: This is raw data. Values are 1, 0, or empty
C1: This is what I'm looking for. I want something along the lines of =IF(B1=1, 0, IF(B1=0, 1, <empty>)) where <empty> is a pure empty that doesn't break the addition formula in column A (empty string breaks the formula). I've found formulas that leave the empty string or a 0, and either of those work in this instance. I want 1 -> 0, 0 -> 1, no value -> no value.
D1: This is raw data. Values are 1, 0, or empty
use ABS:
=IF(B2="","",ABS(B2-1))
And then in Column A sue sum that will ignore the text.
=SUM(C2:D2)

Generate new table from a current table in excel

I have sample table like this:
ID | 1 | 2 | 3
-------------
1 | 0 | 1 | 0
--------------
2 | 1 | 1 | 1
Then I want to generate a new table from that table. It will take the second row (1) then compare with each column (1, 2, 3) then print value of the matrix ( 0 - 1 - 0 ). For example:
Row_ID | Column_ID | Value
--------------------------
1 | 1 | 0
--------------------------
1 | 2 | 1
--------------------------
1 | 3 | 0
--------------------------
2 | 1 | 1
--------------------------
2 | 2 | 1
--------------------------
2 | 3 | 1
I'm not sure how or where to start by using formula. Please help. Thanks,
Well. There's no single formula that's going to do the job, obviously, but we have a few options we can use. I'll assume that the new table is going to start in cell A1 of Sheet2. Adjust accordingly.
Start with manually entered headers
Row_ID | Column_ID | Value
In the first column, first row, enter a 1. In rows below, use this formula: =IF(B3<B2,A2+1,A2) This will increment the value in the first column by 1 each time the second column resets its numbering.
In the second column, first row, enter a 1. The formula we'll use for this one will need some tweaking, but the basic version is: =IF(MOD(ROW()**+1**,**3**)=0,1,B2+1)
This formula is going to essentially count up to a certain point, then reset its numbering. The point it will count to, and where it will reset, will vary depending on the amount of data you have and which row you're starting from. Replace the 3 with the number of data columns you have, and remove the **s. The +1 is needed to increase the Row() counter to the SAME NUMBER as your number of data columns. So in my example, with 3 data columns and starting on row 2, the ROW() function gives us 2, so we need to add 1 to that to get up to a total of 3. If I had 5 data columns, I would add 3 to the total. Hope that makes sense.
These two formulae should give you a set of row and column numbers. Copying the formula down will force the values to increase as needed, thus:
Row_ID | Column_ID | Value
1 | 1 |
1 | 2 |
1 | 3 |
2 | 1 |
...etc.
Finally, to bring in the values, we'll use an OFFSET formula in the Value column: =OFFSET(Sheet1!$A$1,A2,B2) That formula starts from a reference cell - A1, in this case - then moves down x number of rows and across y number of columns to return a value. X and Y are provided by the formulas we already have. Your final structure will be something like this:
Row_ID | Column_ID | Value
1 | 1 |=OFFSET(...
=IF(...|=IF(MOD(...|=OFFSET(...
I hope all that made sense. Please let me know if there's anything that doesn't, and I'll try to troubleshoot.
EDITED TO ADD:
If the Row ID is something like a key that needs to be included with each value, we can get that fairly easily. We'll include another column with a slightly modified OFFSET formula: =OFFSET(Sheet1!$A$1,A2,0)
With this version of the formula we're not changing the column as we go down, just the row when it changes. It allows the values in the first row to be repeated in every row of the table. So this is my input:
And this is my output:
Notice that the ID repeats on each line of the output for the same item.

Only add cells in column when the total of multiple other cells in that row equals 5

So I am getting data fed into a spreadsheet on Google Sheets. I cannot edit that spreadsheet.
I have an additional sheet in the document that totals up the columns in this sheet. The sheet received info such as:
A B C D This info is not actually in the sheet
|------------| \/ \/
| 4 1 0 0 | <-- Valid
| 3 1 1 0 | <-- Valid
| 3 1 0 2 | <-- Invalid
| 3 0 1 1 | <-- Valid
|------------|
The total of each individual row should be 5, but I do not currently have a way of validating this in the form itself. So I need to disregard or remove the data if it is in violation.
So basically, I want to add all the values of column A together, but only of the rows in which the total of these 4 cells are exactly 5; No more, no less.
The furthest/closest I have gotten was using SUMIF, but the I need a single cell indicating whether or not the row totals up to 5, and as I said before, I cannot edit the cells in that specific sheet.
Try this:
=SUMPRODUCT((($A$1:$A$4+$B$1:$B$4+$C$1:$C$4+$D$1:$D$4)=5)*$A$1:$A$4)

Add page series to every second row

I have list of ID extracted from different page numbers. I wanted to add page number to every second row in Excel as shown below:
ID Number | Page Number
1 | 1
2 | 1
3 | 2
4 | 2
5 | 3
6 | 3
7 | 4
8 | 4
9 | 5
10 | 5
Is there any way to do it?
simply use in column B1:
=TRUNC((ROW()-x)/2)+1
while x is the row to start with
Or when matching with ID:
=TRUNC((A2-1)/2)+1
and then auto-fill down (in second case, A2 is the ID to that page -> order of ID's doesn't matter)
If you put values in the first 2 Page number rows then set the 3rd row to be the value of the first row, this forumla can be copied for all remaining rows
| |A|
|1|1|
|2|1|
|3|=A1+1|
|4|=A2+1|
|5|=A3+1|
Enter the following formula into cell B2 and copy down the column:
=ROUND(A2/2, 0)
where A2 is a value from the ID Number column.

How to get cells value from previous visible row in excel formulas

Is it possible to write a formulas in Excel,to calculate value based on the previous visible row?
By applying a Filter on the columns, the previous visible row changes but the usual formals does not consider visibility of the previous row, so the result does not change by applying filters. For example:
Let's original values of the spreadsheet cells be:
A | B | C | D
1: 5 3 1
2: 9 1 1
3: 2 3 0
4: 7 8 1 =A3-B4 equals 2-8=-6
Now assume that we make a filter on C column to hide the third row so we have
A | B | C | D
1: 5 3 1
2: 9 1 1
4: 7 8 1 =A3-B4 is still equals -6 but I want to get: 9-8=1
Is it possible to get such a formulas? Thank you very much.
Try this formula
=LOOKUP(2,1/SUBTOTAL(3,OFFSET(A$1,ROW(A$1:A3)-ROW(A$1),0)),A$1:A3)-B4
The SUBTOTAL/OFFSET part returns a 1 or zero for each value in column A depending on whether it's visible or not, LOOKUP finds the last 1 (equivalent to the last visible value) and gives that value.

Resources