Extract Unique Records Requires Re-Calculation !!!

bisho

Board Regular
Joined
Apr 21, 2012
Messages
85
Hi,</SPAN>

I have 2 questions, the first one is: in the below example I am trying to extract the unique records from A to D, the formula is correct and it does the job only if I recalculate the column D, if I drag down I get only “Red”, if I recalculate I get the correct values !!!! any idea why ?? is there any better formula to use for this purpose ??</SPAN>

Sheet1

*ABCDE
*
Red*Red
Blue*Red
Red*Red
Yellow*Red
Green*Red
Blue*Red
Green*Red
Yellow*Red
Red*Red
Black*Red
Purple*Red

<COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 78px"><COL style="WIDTH: 72px"><COL style="WIDTH: 72px"><COL style="WIDTH: 80px"><COL style="WIDTH: 64px"></COLGROUP><TBODY>
[TD="bgcolor: #cacaca, align: center"]1[/TD]
[TD="bgcolor: #ffff00, colspan: 2, align: center"]Original[/TD]

[TD="bgcolor: #ffff00, colspan: 2, align: center"]Unique[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]

[TD="align: center"]10[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]3[/TD]

[TD="align: center"]0[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]4[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]5[/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]6[/TD]

[TD="align: center"]13[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]7[/TD]

[TD="align: center"]0[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]8[/TD]

[TD="align: center"]18[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]9[/TD]

[TD="align: center"]11[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]10[/TD]

[TD="align: center"]22[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]11[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]12[/TD]

[TD="align: center"]9[/TD]

[TD="align: right"]37[/TD]

</TBODY>

Spreadsheet Formulas
CellFormula
D2{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D1,$A$2:$A$12),0)),"")}
E2=IF(D2<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D2),"")
D3{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D2,$A$1:$A$12),0)),"")}
E3=IF(D3<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D3),"")
D4{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D3,$A$1:$A$12),0)),"")}
E4=IF(D4<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D4),"")
D5{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D4,$A$1:$A$12),0)),"")}
E5=IF(D5<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D5),"")
D6{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D5,$A$1:$A$12),0)),"")}
E6=IF(D6<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D6),"")
D7{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D6,$A$1:$A$12),0)),"")}
E7=IF(D7<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D7),"")
D8{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D7,$A$1:$A$12),0)),"")}
E8=IF(D8<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D8),"")
D9{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D8,$A$1:$A$12),0)),"")}
E9=IF(D9<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D9),"")
D10{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D9,$A$1:$A$12),0)),"")}
E10=IF(D10<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D10),"")
D11{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D10,$A$1:$A$12),0)),"")}
E11=IF(D11<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D11),"")
D12{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D11,$A$1:$A$12),0)),"")}
E12=IF(D12<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D12),"")

<TBODY>
</TBODY>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<TBODY>
</TBODY>


Excel tables to the web >> Excel Jeanie HTML 4 </SPAN>



After recalculation the results are like below and here is my second question, how can I extract the unique records except the ones that their SUMIFS is zero ( I mean do not extract “Blue” in this example)</SPAN>

Thanks.</SPAN>

Sheet1

*ABCDE
*
Red*Red
Blue*
Red*Yellow
Yellow*Green
Green*Black
Blue*Purple
Green***
Yellow***
Red***
Black***
Purple***

<COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 78px"><COL style="WIDTH: 72px"><COL style="WIDTH: 72px"><COL style="WIDTH: 80px"><COL style="WIDTH: 64px"></COLGROUP><TBODY>
[TD="bgcolor: #cacaca, align: center"]1[/TD]
[TD="bgcolor: #ffff00, colspan: 2, align: center"]Original[/TD]

[TD="bgcolor: #ffff00, colspan: 2, align: center"]Unique[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]

[TD="align: center"]10[/TD]

[TD="align: right"]37[/TD]

[TD="bgcolor: #cacaca, align: center"]3[/TD]

[TD="align: center"]0[/TD]

[TD="bgcolor: #c0c0c0"]Blue[/TD]
[TD="bgcolor: #c0c0c0, align: right"]0[/TD]

[TD="bgcolor: #cacaca, align: center"]4[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]18[/TD]

[TD="bgcolor: #cacaca, align: center"]5[/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]31[/TD]

[TD="bgcolor: #cacaca, align: center"]6[/TD]

[TD="align: center"]13[/TD]

[TD="align: right"]6[/TD]

[TD="bgcolor: #cacaca, align: center"]7[/TD]

[TD="align: center"]0[/TD]

[TD="align: right"]9[/TD]

[TD="bgcolor: #cacaca, align: center"]8[/TD]

[TD="align: center"]18[/TD]

[TD="bgcolor: #cacaca, align: center"]9[/TD]

[TD="align: center"]11[/TD]

[TD="bgcolor: #cacaca, align: center"]10[/TD]

[TD="align: center"]22[/TD]

[TD="bgcolor: #cacaca, align: center"]11[/TD]

[TD="align: center"]6[/TD]

[TD="bgcolor: #cacaca, align: center"]12[/TD]

[TD="align: center"]9[/TD]

</TBODY>

Spreadsheet Formulas
CellFormula
D2{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D1,$A$2:$A$12),0)),"")}
E2=IF(D2<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D2),"")
D3{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D2,$A$2:$A$12),0)),"")}
E3=IF(D3<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D3),"")
D4{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D3,$A$2:$A$12),0)),"")}
E4=IF(D4<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D4),"")
D5{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D4,$A$2:$A$12),0)),"")}
E5=IF(D5<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D5),"")
D6{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D5,$A$2:$A$12),0)),"")}
E6=IF(D6<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D6),"")
D7{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D6,$A$2:$A$12),0)),"")}
E7=IF(D7<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D7),"")
D8{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D7,$A$2:$A$12),0)),"")}
E8=IF(D8<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D8),"")
D9{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D8,$A$2:$A$12),0)),"")}
E9=IF(D9<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D9),"")
D10{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D9,$A$2:$A$12),0)),"")}
E10=IF(D10<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D10),"")
D11{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D10,$A$2:$A$12),0)),"")}
E11=IF(D11<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D11),"")
D12{=IFERROR(INDEX($A$2:$A$12,MATCH(0,COUNTIF($D$1:D11,$A$2:$A$12),0)),"")}
E12=IF(D12<>"",SUMIFS($B$2:$B$12,$A$2:$A$12,D12),"")

<TBODY>
</TBODY>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<TBODY>
</TBODY>


Excel tables to the web >> Excel Jeanie HTML 4 </SPAN>
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
hi

Maybe the simplest options is a pivot table - it requires no formulas or code. A query table might similarly be an option. Set up the pivot table from a new file. Assuming you have current headers MyColor & MyValue and the source data table is named MyData the SQL would be like below. From the new file ALT-D-P & follow the wizard, choosing external data source at the first step. At the last step choose the option to edit in MS Query. The absolute value > 0.0001 is to avoid rounding errors for zero sums that are non-zero due to floating point errors. Use the same SQL if you choose a query table - ALT-D-D-N & follow the wizard.

HTH

Code:
SELECT MyColor, SUM(MyValue) AS [MyValue]
FROM MyData
GROUP BY MyColor
HAVING ABS(SUM(MyValue))>0.0001
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top