I have a two tabs (data) and (summary).
My data tab looks something like this (mine has more columns but this gives you an idea:
The column order repeats every 9 columns.
In my summary tab I want it split out and a SUM of the 8th of 9 column grouped by the 1st of 9 column.
Example output from the numbers above:
ALPHA 45
BETA 53
CHARLIE 45
I have tried doing a VLOOKUP but this just brings back a single value.
How can I do a VLOOKUP that sums all found?
As a crude solution, SUMIF should do the job.
=SUMIF(A1:A7,"ALPHA",H1:H7) + SUMIF(A1:A7,"ALPHA",Q1:Q7) + SUMIF(A1:A7,"ALPHA",Z1:Z7)
If the total number of column groups isn't known you may need something more elaborate.
You probably need to use INDEX not Vlookup
and then follow the example bellow
Check this post as well
Related
I have a pivot table and I use =INDEX($A$5:INDEX($A:$A,COUNTA($A:$A)) to know the numbers of rows in the pivot table. I then use this number to calculate the top 5 using
=LARGE(Array,{1;2;3;4;5}) which works fine, but when I use
=LARGE((array1-array2),{1;2;3;4;5}) it give me #N/A as a result; array1 and array2 are base on the formula above (=INDEX($A$5:INDEX($A:$A,COUNTA($A:$A)))
I try using it by parts to see if there is something wrong, but when I use
=$B$5:INDEX($B:$B,COUNTA($B:$B))-$E$5:INDEX($E:$E,COUNTA($E:$E)) itself it gives me what I need but when I use that in the array part [Large(array,k)] to see the top 5 it give me #N/A...
Any help or ways to go around that problem would be appreciated.
Edit:
Product
2001
2000
Varriacion
Pencil
100
150
-33%
Pen
150
130
+15%
Table
40
50
-20%
I use =INDEX($A$2:INDEX($A:$A,COUNTA($A:$A)) to know the number of rows in the pivot table in this case 3 and outside the Pivot Table I calculated the top 3 variation using =LARGE($D$2:INDEX($D:$D,COUNTA($D:$D)),{1;2;3}) and then use =INDEX($A$2:INDEX($A:$A,COUNTA($A:$A)),MATCH(Result[1],=INDEX($D$2:INDEX($D:$D,COUNTA($D:$D)),0)) to match the number with the respective product automatically.
Result[1]: This is the result cell from the Large() formula in the side
This works fine, when I change from product to location (example) it will update and I will see the top three in the calculations in the side. But When I do it to know the absolute variance (column 2001 - column 2000) I do :
=LARGE($B$2:INDEX($B:$B,COUNTA($B:$B))-$C$2:INDEX($C:$C,COUNTA($C:$C)),{1;2;3}) and in here i get the #N/A so I cant get the Top 3.
When I manually do =$B$2:INDEX($B:$B,COUNTA($B:$B))-$C$2:INDEX($C:$C,COUNTA($C:$C)) to see if is posible to get the result this way I get the difference in the respective cells but when I use that as an Array in the Large() formula i won't work.
*The variance column is not part of the Pivot table, is just something I add next to it so I can also see the variation and is already automated by using the GetPivot() formula. The pivot table information in this example is just Product, 2001 and 2000.
Replicating your setup, I get the result you want, without #N/A errors.
From comments, you have blanks in you Pivot data. These will cause the COUNTA to return invalid results.
The solution is to COUNTA a column with no blanks. Column A serves that purpose
=LARGE($B$2:INDEX($B:$B,COUNTA($A:$A))-$C$2:INDEX($C:$C,COUNTA($A:$A)),{1;2;3})
Demonstration of the problem
I just understood why I got #N/A ... the problem with the example was that it was shown as a table and in a pivot table the header is different... in column B1 there is always "Column labels" while in the rest of the columns there is just empty space where you can't modify since is Pivot Table. So since I used $B$2:INDEX($B:$B,COUNTA($B:$B))-$C$2:INDEX($C:$C,COUNTA($C:$C)) the COUNTA($B:$B)) will give me 1 more than the others, in this case COUNTA($C:$C) .
After fixing the formula to equalize the columns counts for all cases it fixes the problem.
Thanks for the help.
I have array of numbers in a single column like this:
I want only that numbers for which corresponding negative numbers exist. If number exist 2 times, but negative number exist only one time, then I wanted to retain one positive and one negative number. Similarly, if number exists 3 times, and negative number appears only two times, then I want 2 set of numbers including positive and negative. In this case, I wanted to get output:
5 2 -2 -5
Orders of numbers are not relevant for me. Please do not use VBA. You can create multiple column and apply filter at the end.
Thank you for the response, but I wanted to get the data in column next to the values. Like:
5
2
-2
-5
Please help.
Here's another Office 365 solution:
Name the data range DATA
Put this formula anywhere: =CONCAT(REPT(-ROW(A1:A100)&" "&ROW(A1:A100)&" ",COUNTIF(DATA,"="&ROW(A1:A100)*IF(COUNTIF(DATA,"="&-ROW(A1:A100))<COUNTIF(DATA,"="&ROW(A1:A100)),-1,1))))
That will output the pairs into one cell.
Here's a slightly modified Step 2, which excludes duplicates: =CONCAT(IF((COUNTIF(DATA,"="&-ROW(A1:A100))>0)*(COUNTIF(DATA,"="&ROW(A1:A100))>0),-ROW(A1:A100)&" "&ROW(A1:A100)&" ",""))
Looks like this:
The data doesn't need to be sorted. Both methods work up to 100, but you can easily expand that by changing A100 to A1000 or whatever you need.
Use the vlookup formula to identify the rows, and you can use the Filter & Unique formula to get the list, or a pivot table.
First, immediately next to your data use the formula:
=vlookup(A1*-1,$A$1:$A$1,1,0)
For non-365:
This will produce an error for each instance that doesn't have a match. You can filter at this point to get your list from the existing table. You can also create a pivot table under the Data tab of your ribbon and inserting a pivot table. Filter the #N/A from there to get an exclusive list without hidden rows.
For 365:
You can use the following combination of formulas to get the exclusive list as well.
=UNIQUE(FILTER(B1:B8,ISNUMBER(B1:B8)),0,0) or =UNIQUE(FILTER($B$1:$B$8,ISNUMBER($B$1:$B$8)),0,0) should yield the same results
As ScottCraner mentioned, you can circumvent the helper column in 365 by modifying the formula a bit more:
=UNIQUE(FILTER(A1:A8,ISNUMBER(MATCH(-A1:A8,A1:A8,0)),"")
The Match here is doing something similar to the Vlookup, but housing that logic within the formula, so it's a cleaner solution in my opinion.
Using your data the result was { -5,-2,2,5 }
These are spill formulas so you only need to put it in one spot and it will expand the formula over the adjacent cells below where it's entered for however many cells needed to list all the unique numbers that occur. It takes into account the negatives and so on. This may be a 365 formula, so if you're on another version of excel it may not work.
Edit: Adjusted the instructions to fully address the question.
I have the following table:
and I'd like to have the total for each player but values are every 3 columns.
As you can see from the picture on the bottom part I wrote what manually I should enter.
For player 1
=SUM(D3;G3;J3...)
Player 2
=SUM(D4;G4;J4...)
and so on. What formula should I use to calculate automatically every 3 columns? I know how the MOD works but on the net I found too many examples each one using different methods and none worked so far. Can anyone help me please or point me to the right direction to understand how it works to get this data since I'll be using this a lot (get value from cell every nth column).
thanks
It looks like you should just be using SUMIFS here:
=SUMIFS(3:3,$2:$2,"TOT")
This will sum every value on row 3 (Player 1) where the value in row 2 is "TOT" (every 3rd column). Put this in cell B18 and just copy down in your column B.
Or, in case you change your column labels, you can refer to cell D2 instead of typing "TOT" in the formula:
=SUMIFS(3:3,$2:$2,$D$2)
Try this, it will total all the cells that occur every 3 columns beginning at column D. Z3 can be increased to any column you require:
=SUMPRODUCT((D3:Z3)*(MOD(COLUMN(D3:Z3)-1,3)=0))
The explanation on how it works can be found here (I advise you to bookmark this site for future references. They have many other helpful formulas and functions).
Applying this formula to your reality should be something like this for Player 1 (Not tested. Adjust the ranges as required):
=SUMPRODUCT(--(MOD(COLUMN(D3:Z3)-COLUMN(D3)+1,3)=0),D3:Z3)
In my sheet I have a Column1 with text and a Column2 with random numbers.
I would like to get a Column3 with the five "highest texts" for example:
I know I can get the text if I make an Index/Match looking for the number, but I'm lost at the sorting part.
Place this in cell C1 and drag down:
=LOOKUP(REPT("z",255),IF(LARGE($B$1:$B$10-(ROW($B$1:$B$10)/9^9),ROWS($A$1:A1))=$B$1:$B$10-(ROW($B$1:$B$10)/9^9),$A$1:$A$10))
This needs to be entered with CTRL + SHIFT + ENTER.
Use a 'helper column' to get the top 5 numbers with the LARGE function then use INDEX on column A, returning the appropriate row number with AGGREGATE and COUNTIF function to offset duplicates.
additional variant to already posted:
=INDIRECT("A"&MATCH(LARGE(B:B,ROW(A1)),B:B,0))
test:
The question is: What if there is not a clean break between 5th and 5th place? For example what if f was also a 6? This would then be tied for with the others how does one descriminate?
The following will bring out only the 1st through the 5th but allow for ties that might push the actual number past 5 due to ties.
Put the following in C2:
=IF(OR(ROW(1:1)<=5,COUNTIF($C$1:$C1,INDEX($A$1:$A$10,MATCH(LARGE($B$1:$B$10,ROW(1:1)),$B$1:$B$10,0)))>0),INDEX($A$1:$A$10,MATCH(1,INDEX(($B$1:$B$10=LARGE($B$1:$B$10,ROW(1:1)))*(COUNTIF($C$1:$C1,$A$1:$A$10)=0),),0)),"")
It is an array formula and must be confirmed with Ctrl-Shift-Enter. Then copy it down ten rows(in the picture the formula is copied down ten rows).
Now we change f to be 6 so it is tied for fifth:
And it gets added to the list.
You could just limit the output to five rows. But then it would be excel deciding what is the top five. If this is what you want than any of the other answers will work.
I have a dataset on excel with more than 40k entries, and there are 2 columns.
I want to find if there exists an entry for example with 1 in the first column and 1687 in the second column, I tried using this following IF function:
=IF(COUNTIF(B2:B178,"1687"),"Yes","No)
where A1:A178 have 1 in the first column.
This function works perfectly alright, however in terms of selecting the range for Countif, it requires much work as sometimes the range i have is more than 3 to 4k. This is way too time consuming as I have to repeat this search for many pairs of numbers.
I then tried by adding a helper column, where the 1st entry would be "=A2&B2"
My plan was to search this entire helper column for "11687" instead, however this fails to identify entries where it has 1 in the first column, 1687 in the second, and 11 in the first column, and 687 in the second column.
Ideally if the "find" function (Ctrl+F) could find 2 columns for different values it will be exactly what I need.
Could anyone please advise me on how to do this search?
Thank you very much!
Try this formula and fill it all the way down, should be more efficient than COUNTIF:
=IF(AND($A1="1",$B1="1687"),TRUE,FALSE)
Then you have a column of TRUE/FALSE that you can use to do what you want.
Change your range into a table and use built in Excel filtering capabilities. See http://office.microsoft.com/en-001/excel-help/filter-data-in-a-range-or-table-HP010073941.aspx#BMfilter_text