Remove Duplicates and Sum Formula - excel

I have a set of data that will change so I need a formula to dynamically get a result.
From this set of data I end up with two columns, Dates and Amounts, like the following:
What I need is to be able to remove the duplicates from the Dates column, while summing the corresponding amounts. So each unique date will have its own row with an amount that is a sum of all the amounts with this date.
Desired Result:
How would I go about this? Can I do it in a formula or do I need VBA?
Fairly new to excel, thanks in advance.

As an alternative to pivot tables in C1 enter:
=MIN(A1:A100)
In C2 enter the array formula:
=IF(MIN(IF($A$1:$A$100>C1,$A$1:$A$100))<C1,"",MIN(IF($A$1:$A$100>C1,$A$1:$A$100)))
and copy down.Apply a Date format to column C.Column C extracts the unique dates from column A.
In D1 enter:
=SUMPRODUCT(--($A$1:$A$100=C1)*($B$1:$B$100))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

Related

excel SUMIFS only on same date

I'm trying to create a formula in column K which sums all cells that apply , in column J, only when the following conditions are true:
dates are the same in column A
AND client name is the same in column B
For example, in cell K2, I want the sum of J2+J3+J4 because A2=A3=A4 and B2=B3=B4.
K5=J5 only, because there are no other dates with the same client name.
K6=J6+J7 because A6=A7 and B6=B7.
What kind of formula would I use for this? I can't figure out how to do it with a SUMIFS.
I would try using a pivot table with:
The names as row values
The dates as the column values
And funds received using SUM in the values column
Edit
Based on #pnuts comments here is how to get the values in column K. Put this in K2 and drag down.
=IF(OR(COUNTIFS($B$1:B3, B3) = 1, B3 = ""), SUMIFS($J$2:J2, $A$2:A2, A2, $B$2:B2, B2), "")
This formula will give blank values until the formula finds a new client on a new date. However, I still think using pivot table is a better solution.
However, I still find the pivot table
In cell K2 put following formula:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,SUMIFS($J$2:$J$10,$A$2:$A$10,A2,$B$2:$B$10,B2),"")
Adjust row 10 value. It will be last row of your actual data.
Copy down as much you need.
EDIT
Uploaded file shows the cause behind formula not working correctly for you. It turned out to be whitespace characters in column B (names) data e.g.
Cell B3: "Moe John" has a trailing space.
Cell B10: Same case with "Doe Jane"
If you want to use above posted formula then all names shall be corrected. Or alternatively to deal with spaces you can adopt below approach.
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,"*"&TRIM(B2)&"*")=1,SUMIFS($J$2:$J$28,$A$2:$A$28,A2,$B$2:$B$28,B2),"")
Notice the change in COUNTIFS formula where B2 is now replaced with "*"&TRIM(B2)&"*".
Even such formula will take a beating if you have uneven whitespace characters in between your data. I'd suggest normalizing it as much as possible.

I need to find an excel formula that I can use to create a unique list of Item numbers from an array

I need to find an excel formula that I can use to create a unique list of Item numbers from an array. I do not want to count them I just want to make a list of the Item Numbers. These part numbers are actually Alpha Numeric and can have repeating numbers through out the array multiple times. There is one other catch this list will have empty cells in it and could also be the first record in the array. This data is being pulled into Excel through a Jet report add-in for Excel.
Example: Starting in cell A1..A9
Item No.
<BLANK>
7810042050
783979
7810006045
7810006042
7810006032
<BLANK>
7810006022
7810006032
With values in column A, in C1 enter:
=MAX(A1:A10)
in C2 enter the array formula:
=MAX(IF(A$1:A$10<C1,A$1:A$10,""))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
EDIT#1:
Chris Neilsen has pointed out that the values in column A are actually Text rather than Numeric. To accommodate this, two changes must be made to the formulas:
A1 must be excluded
the alphas must be converted to numeric.
So we will replace the normal formula:
=MAX(A1:A10)
with the array formula:
=MAX(--(A2:A10))
and replace:
=MAX(IF(A$1:A$10<C1,A$1:A$10,""))
with the array formula:
=MAX(IF(--(A$2:A$10)<C1,--(A$2:A$10),""))
and then copy down.
If you have alpha characters in the part numbers you can do this in 2 steps.
Both are array formulas and you need to use Ctrl-Shift-Enter
Col B - sorted list of items in Col A
B2 =IFERROR(INDEX($A$2:$A$10,MATCH(COUNTA($A$2:A2),COUNTIF($A$2:$A$10,"<="&$A$2:$A$10),0),1),"")
Col C - eliminate the duplicates
C2 = IFERROR(INDEX($B$2:$B$10, MATCH(0, COUNTIF($C$1:C1, $B$2:$B$10), 0)),"")
Copy both formulas down.
I tried to combine the two formulas but nesting an array (results in Col B) with varying row ranges did not work out. I could not find a way but the two formulas together will work.
Enter this Formula Array in B2 and copy to B3:B10
FormulaArrays are entered pressing [Ctrl] + [Shift] + [Enter] simultaneously, you shall see { and } around the formula if entered correctly
=IFERROR(
INDEX($A$2:$A$10,
MATCH(1,1+COUNTIF($B1:$B$1,$A$2:$A$10)+(($A$2:$A$10="")*1),0)*1),"")

Last Status By Date and Count

I want to extract the last status of a item by date from the sample data given below:
http://i.stack.imgur.com/T4I5W.png
I want the following result:
http://i.stack.imgur.com/xDF55.png
Can this be achieved using a formula or PivotTables?
With pivot table you can easily extract the max date of each item. But the status will be problematic.
So, the best way to do it, is not with a pivot table. but with 3 steps.
1) copy your item list to another sheet to the first column. (I will assume the your first sheet is Sheet1 and the 2nd is Sheet2) choose the entire column in the 2nd sheet and remove duplicates. (date ribbon -> remove duplicates)
2) find your max data for each item.
lets assume your first rows is header so in the 2nd rows on column b enter:
=max(if(Sheet1!b:b=b3,Sheet1!a:a,""))
Note that this an array formula so you have to enter this using ctrl+shift+enter
Now drag this formula to the end of rows
3) find the last status of each item
you have to do double lookup formula
on c2 enter:
=index(Sheet1!c:c,match(a2&b2,Sheet1!b:b&Sheet1!a:a,0),1)
Again, that this an array formula so you have to enter this using ctrl+shift+enter
And again, drag this formula to the end of rows.
Actually this can be done only with formulas and without copying the data in another worksheet.
Assuming your data is in the range A1:C16 (change as needed) then you can enter the following Array Formulas (press [Ctrl]+Shift]+[Enter] together):
Enter "Item" in E1 and this array formula in E2 then copy down till last record (E16 for this sample)
=IFERROR(INDEX($B$2:$B$16,MATCH(0,COUNTIF(E$1:E1,$B$2:$B$16),0)*1),"")
Enter "Date” in F1 and this array formula in F2 then copy down till last record (F16 for this sample)
=IF($E2="","",MAX(IF($B$2:$B$16=E2,$A$2:$A$16,"")))
Finally Enter “Status” in G1 and this array formula in G2 then copy down till last record (G16 for this sample)
=IF($E2="","",INDEX($C$2:$C$16,MATCH($E2&$F2,$B$2:$B$16&$A$2:$A$16,0),1))
Ranges within the formulas should be adjusted as needed, no need to point to all rows in the worksheet.

Vlookup to check two conditions

I am referring to below my google spreadsheet
https://docs.google.com/spreadsheets/d/1dCfShenhV2j98q5wkOXMeyWj9tlMZbaBgBqB2vAPdHo/edit?usp=sharing
I am looking to update H,I and J columns using vlook formula in way that it should match both name and date values in my data range, which in A,B and C columns
Here is the issue I am facing with normal vlookup is that I can check only name.It is ignoring the date and updating the vlooked up data on all date column.
Eg: Alpha and date 20141120 value is 10, it should fill only H3, but it is updating, H3 I3 and J3 with value 10
I really appreciate your answer on this problem!!!
you can use this formula of index and match:
=IFERROR(INDEX($A:$C,MATCH(1,($A:$A=$G3)*($B:$B=H$2),0),3),"")
paste it in the first cell of your table H3, and drag and fill to the right and then select the entire row and fill down till end.
it should work.
if error(();"") : you will get empty cells if there is no match.
this is an array formula, so press ctrl+shift+enter to calculate the formula
UPDATE: here is [the example sheet downloadable from here}(https://www.dropbox.com/s/clqxsj5j4bdk27b/indexmatch.xlsx?dl=0)
Basically you need to concatenate the results, then use a VLOOKUP on that.
I.e. insert a column between B and C, with formula "=CONCATENATE(A2,B2)"
In the range you want to update, use the column and row headings for you lookup
"=VLOOKUP(CONCATENATE($g3,h$2),$c$1:$d$3,2,false)"
You want to perform a Multiple Lookup (see this).
As indicated there, enter
=IFERROR(LOOKUP(2,1/($A$1:$A$3=$G3)/($B$1:$B$3=H$2),$C$1:$C$3),"")
in H3. Copy into H3:J5.
This avoids array formulas.

Excel - Count cells according to occurrence

In the above eg- it should show the count value - 8
This requires an array formula. To enter an array formula, enter the formula into a cell and then hit Ctrl+Shift+Enter.
=SUM(IF(COUNTIF(OFFSET(A1:C5,ROW(A1:C5)-1,0,1,3),"<>""")>0,1,0))
Put this formula in D1:
=IF(COUNT(A1:C1)>0,1,0)
Copy the formula down for as many rows as you have.
Take the sum of column D.

Resources