Pivot table generating custom value by comparing the 2 column's - excel

I have below table.
Identity_No Date1 Date2
123 1/6/2018
456 4/7/2018 8/8/2018
567 10/10/2018 6/12/2018
now i need to generate a table like below
Identity_No 1/6/2018 4/7/2018 8/8/2018 10/10/2018 6/12/2018
123 y n n n n
456 n y y n n
567 n n n y y
please let me know how to create it with pivot function or any other option.

you can achieve this with combination of formulas(if your data structure is as presented). If your values are in range A1:C4, please enter this formula in cell G1 and drag it to the right. You must enter this formula with CTRL+SHIFT+ENTER combination since it is an array formula.
=NUMBERVALUE(INDIRECT(TEXT(MIN(IF(($B$2:$D$9<>"")*(COUNTIF($F$1:F1,$B$2:$D$9)=0),ROW(2:9)*100+COLUMN($B:$D),7^8)),"R0C00"),)&"")
This way you will extract unique dates from your range of dates in B:C columns.
then in cell f2 enter formula =A2 and drag it to the bottom. In cell G2 enter this formula =IF(IFNA(MATCH(G$1,$B2:$E2,0),"n")="n","n","y") and drag it beneath whole table.

Related

Return Multiple Unique Matches in Excel without Array Formula

Given an Excel table of shape
Col. A Col B Col. C Col. D Col. E
x 2 x 2 3
x 3 y 7
y 7 z -5
x 2
z -5
I want to return the first unique hit in Column B for argument "x" in Column D,
the second unique hit in Column B for argument "x" in Column E and so forth.
The formula I'm currently using in cell D1 for this is
{=IFERROR(INDEX($B$1:$B$5,MATCH(0,COUNTIF($C1:C1,$B$1:$B$5)+($A$1:$A$5<>$C1),0)),"")}
which is working.
The problem I'm having is that since this is an array formula and since I'm analyzing a decent amount of data computation time for my sheet is too high.
Is there an alternative for this functionality avoiding an array formula?
Thanks!
Haven't got time to test this properly, but if you have Excel 365 you can use a single formula per row and it may be faster:
=TRANSPOSE(UNIQUE(FILTER(B1:B10,A1:A10=C1)))
in D1.
EDIT
To pull the formula down, you need static references as OP has pointed out. Probably should check for empty cells in column C as well, so formula becomes:
=IF(C1="","",TRANSPOSE(UNIQUE(FILTER(B$1:B$10,A$1:A$10=C1))))

Finding rows where col A & B match and sum of col C = 0

Hi all,
I am looking for a way to find rows under the following conditions:
Values of column A matches, values of column B matches AND values of column C add to 0.
I&apos;ve tried sumproduct on conditional formatting without much success.
=SUMPRODUCT(($C$1:$C$9)*($A$1:$A$9=$A1)*($B$1:$B$9=$B1))=0
Perhaps VLOOKUP could be used? Any suggestion would be appreciated!
I'm using two helper columns. You could hide these in your spreadsheet. Col E = colA & colB. Col F has this formula:
SUMIFS(C$1:C$8, E$1:E$8, E1) = 0
This says if the sum of values in col C = 0 where col E matches the current row, TRUE, otherwise FALSE.
Then I added a conditional rule for A1:C8 to highlight in yellow. The rule is
=$F1
This says to highlight the row if the col F is true for that row. I think this will do what you want.
Note that my highlighted results are different than yours. You show 2 rows of 1015 in Col A + B in Col B as highlighted. Why would this be? (50) + 50 + 50 does not = 0? (Thanks to Jerry J for pointing this out.)
Maybe someone more clever than I can figure out how to do it without helper columns. Until then, here is one way to do it:
You need just one helper column - a column that does a running total for each value of A and B. So, put this in D2 and copy it down all the way to D9:
=SUMIFS($C$2:$C2,$A$2:$A2,$A2,$B$2:$B2,$B2)
That will sum all the values above the current cell that have the same A and B. What that does is find where the rows finally sum to zero.
Then you can use this in your conditional formatting:
=COUNTIFS($D2:$D$9,0,$A2:$A$9,$A2,$B2:$B$9,$B2)
That will find the zero below the current cell that has the same A and B. So, it doesn't include cells that have the same A and B that are below the 0.
If you put that second formula in E2 and copy it down all the way to E9 it looks like this:
A
B
C
D
E
Deal
Item
USD
Running Total
Conditional Formatting
1010
A
100
100
1
1015
A
-100
-100
0
1010
A
-99
1
1
1010
A
-1
0
1
1010
B
-100
-100
0
1015
B
-50
-50
1
1015
B
50
0
1
1015
B
50
50
0
If it's not a huge table and you want all rows where A and B match, try this:
=SUMIFS($C$2:$C$9, $A$2:$A$9, A2, $B$2:$B$9, B2) = 0
Or, if you highlight your rectangle and Insert - Table then make a new column with a formula of
=SUMIFS([USD], [Deal], [#Deal], [Item], [#Item]) = 0
then use that column for your conditional formatting formulas and, if you wish, hide the column. That way it's easier to read, you only need to enter the formula once instead of dragging it down the column, and it will store it once instead of once per row.
If it is a huge table then you are going to want to make a pivot table and then use that, because executing this for every row in your raw table will probably be a lot slower than a pivot table would, but using a pivot table is less user-friendly because the changes aren't instant unless you do some VBA to refresh the pivot table anytime something changes.

Find all increments of +1's starting from a given number in a column in excel

I have 2 columns x and y
x Y
0 1
1.645 7.897
3.444 6.4387
2.345 5.9090
3.890 5.4322
4.789 3.4321
5.666 4.1111
keeping x at a constant value ( say i pick 3.890) i want to find all increments of +1's of the corresponding Y column . In the above example I want (5.4322 + 1 + 1 + 1 ) upto a certain range.In the above example i want the values (6.4387, 7.987) .If an exact +1 value does not exist i want the closest value to it .Is there a formula i can use to achieve this in excel ? . Any help is much appreciated.
expected output :
New column
5.4322
6.4387
7.897
Suppose you have the following named ranges:
x being values under x column;
y being values under y column;
Pick_x being the selected value from x column.
Enter the following formula in Cell G2 and drag it down to G8:
=IF(INDEX(y,MATCH(Pick_x,x,0))+1*(ROW(A1)-1)>MAX(y),"",INDEX(y,MATCH(Pick_x,x,0))+1*(ROW(A1)-1))
It will return the corresponding y value +1s based on the selected x value, but will show blank if the +1 value is outside the range set by y column.
Then enter the following array formula (confirm by pressing Ctrl+Shift+Enter in the formula bar) in Cell H2 and drag it down to H8:
{=IFERROR(INDEX(y,MATCH(MIN(ABS(y-G2)),ABS(y-G2),0)),"")}
It will return the corresponding closes match from y column based on the value in Column G, and return blank if there is no value in Column G.
I used Column G as a helper column but you can choose to replace G2 in the second formula with the first formula, but it will make the formula too long to be easily understood.
If I change the x value to 4.789, Column H will return the following:
Let me know if I've misinterpreted your question. Cheers :)

Google Sheets - formula to return N first values from range A where MAX(range B)

F1:N1 with random numbers (can have duplicates).
F2:N2 with sorted numbers.
Need a formula to fill in A1:C1 with values from F2:N2 where F1:N1 has a maximum value.
In the example it should be 1,8,3 from F2:N2 - according to 9,9,8 from F1:N1.
_ A B C D E F G H I J K L M N
1 ? ? ? 9 3 8 1 5 5 3 9 8
2 1 2 3 4 5 6 7 8 9
You can do this with a "helper row" to create a list of unique ranks:
F3: =RANK(F1,$F$1:$N$1)+COUNTIF($F$1:F1,F1)-1
and fill right to N3
Since your values in F2:N2 are sequential {1...8}, you can use this formula:
A1: =MATCH(SMALL($F$3:$N$3,COLUMNS($A:A)),$F$3:$N$3,0)
and fill right to C1
If the values in F2:N2 are random, then you can use this:
A1: =INDEX($F$2:$N$2,1,MATCH(SMALL($F$3:$N$3,COLUMNS($A:A)),$F$3:$N$3,0))
and fill right to C1
Nobody has jumped in to offer a Google Sheets solution so here is one:
=query(transpose(sortn(transpose(F1:N2),3,,1,false,2,true)),"select Col1,Col2,Col3 limit 1 offset 1")
In A1. This is a self-expanding formula so does not need to be filled across and does not need helper rows.
EDIT
'Limit 1' may be omitted in the above formula as mentioned in the comment.
Also this is a little shorter:
=transpose(query(sortn(transpose(F1:N2),3,,1,false,2,true),"Select Col2"))
Formula in A1 = INDEX($F$2:$N$2,MATCH(COLUMN(A1),$F$3:$N$3,0)) and is dragged till C1
Formula in F3 = RANK(F1,$F$1:$N$1)+COUNTIF($F$1:F1,F1)-1 and is dragged till N3

SUMIF a cell on the same row, in a certain column, contains a specific text

I'm trying to sum all transactions on a spreadsheet of my bank statement. Let's say I have the following under columns B-F:
B C D E F G
Date Type Transaction Value Balance ???
row 4 23/05/14 BAC Bank transfer A 1103.55 637.03
row 5 23/05/14 POS Pizza purchase 10.00 627.03
row 6 23/05/14 POS Coffee purchase 10.00 627.03
I'd like to make a new cell on column G which sums all values in column E that are on rows containing "POS" in column C. Is this possible?
Yes and I believe the simplest way is by using SUMIF:
=SUMIF(C:C, "POS", E:E)
In other words, sum E:E if C:C equals "POS".
=SUM(IF(C4:C6="POS",1,0)*E4:E6) is one way. Expand the ranges to taste.
Note this is an array formula: you need to press Ctrl + Shift + Return once you're done editing.

Resources