Help me fix a SUM formula please

Jyggalag

Active Member
Joined
Mar 8, 2021
Messages
445
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi all,

I have this formula:

=IFERROR(SUM(IF(FREQUENCY(IF($A$2:$A$101=A2;IF($D$2:$D$101=D2;IF($H$2:$H$101=H2;MATCH($I$2:$I$101;$I$2:$I$101;0))));ROW($A$2:$A$101)-ROW($A$2)+1);1));"0")

It checks the following sheet (please note that A2, A3 and A4 have the same value):
'
1683200754797.png


I want the formula to look at the value in A2. After this, it has to look up if A2 appears anywhere else in column A, and if the value of A2 does indeed appear anywhere else, it has to check if the respective values for this row in column D, H and I match the values in D2, H2 and I2. If they do, it should return the value "1", because they are the same item. However, if a single value in either D, H or I deviate, it should add it, so B2 returns "2", and "3" if it finds two more, and "4" if it finds 3 more unique values and so on.

I hope this makes sense? I have tried to do it above, but my formula is not working. It correctly returns "0" for row 5 and 6, as these have no values in columns D, H, and I.
It also correctly returns "2" for row 3 and 4, as the values in row 2 and 3 are similar.
However, it incorrectly returns "1" in cell B2, because clearly I4 is different from I3 and I2 and these rows have the same value in column A, so they are the same item, but with a different value in column I, which should then return the value "2".

I know this is very complex, but I would GREATLY appreciate if someone could fix my formula! :)
 
what is your expectation with this:
mr excel questions 34.xlsm
ABCD
9ADHI
10name1XYZ
11name1ABC
12name1XYZ
13name1ABC
jyggalag
Since it is the same name in column A from row 10-13, the column where the formula is inserted (maybe column E10-E13 in your case, I use column B) should return the value "2" as there are a total of 2 different variations for "name1"

and for row 9 it should return "1" as there is only one variation of this, which is the combination of "A", "D", "H" and "I" as values
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
i was using row 9 to indicate the columns in your scenario. Sorry for the confusion.

please let me know what your expectations are in these scenarios:



mr excel questions 34.xlsm
ABDHIJ
9Expectation?
10name11XYZsame as 12
11name11ABCsame as 13
12name12XYZsame as 10
13name12ABCsame as 11
14name13QRSsame A, diff rest
15name14JKIsame A diff rest
16
17what if sorted this way:
18name11XYZsame as 23
19name11ABCsame as 20
20name12ABCsame as 19
21name13QRSsame A, but the rest is different
22name14JKIsame A, but the rest is different
23name12XYZsame as 17
jyggalag
 
Upvote 0
The way it is sorted does not matter.

Since it is the same name in column A all the way through, column B should have the same results, as it is looking up "name1" in all the rows

and this result should be: 4, since there are a total of 4 different combinations for the values in column D-I, which are:
combination 1: "name1, X, Y, Z"
combination 2: "name1, A, B, C"
combination 3: "name1, Q, R, S"
combination 4: "name1, J, K, I"

Does this make sense? :) I know I am setting up a super confusing task :(
 
Upvote 0
okay. so you want to count the unique combinations for A of D,H,I?
 
Upvote 0
The way it is sorted does not matter.

Since it is the same name in column A all the way through, column B should have the same results, as it is looking up "name1" in all the rows

and this result should be: 4, since there are a total of 4 different combinations for the values in column D-I, which are:
combination 1: "name1, X, Y, Z"
combination 2: "name1, A, B, C"
combination 3: "name1, Q, R, S"
combination 4: "name1, J, K, I"

Does this make sense? :) I know I am setting up a super confusing task :(

okay. so you want to count the unique combinations for A of D,H,I?
Yes exactly! :)
 
Upvote 0
ok, then try this:

i'm sorry, my comment about I, it is text in I2,I3, number in I4.


mr excel questions 34.xlsm
ABDHIJ
1Identifiernumberwhateverfinal datenumber
2name1325-01-202325-01-20241000000
3name1325-03-202325-01-20241000000D3 <> D2
4name1325-03-202325-01-202450000<< text in I
jyggalag
Cell Formulas
RangeFormula
B2:B4B2=COUNTA(CHOOSECOLS((UNIQUE(HSTACK($A$2:$A$4,$D$2:$D$4,$H$2:$H$4,$I$2:$I$4),FALSE)),1))
 
Upvote 0
ok, then try this:

i'm sorry, my comment about I, it is text in I2,I3, number in I4.


mr excel questions 34.xlsm
ABDHIJ
1Identifiernumberwhateverfinal datenumber
2name1325-01-202325-01-20241000000
3name1325-03-202325-01-20241000000D3 <> D2
4name1325-03-202325-01-202450000<< text in I
jyggalag
Cell Formulas
RangeFormula
B2:B4B2=COUNTA(CHOOSECOLS((UNIQUE(HSTACK($A$2:$A$4,$D$2:$D$4,$H$2:$H$4,$I$2:$I$4),FALSE)),1))
it does not work unfortunately :(

1683206234873.png


I inserted it into B2 like this: =COUNTA(CHOOSECOLS((UNIQUE(HSTACK($A$2:$A$1001;$D$2:$D$1000;$H$2:$H$1000;$I$2:$I$1000);FALSE));1)) (took it down to row 1000)

and it returns "6", which makes no sense to me, as there are only 2 variations of "name1" in those rows

likewise, it should return "1" on row B5 and B6
 
Upvote 0
it does not work unfortunately :(

View attachment 90960

I inserted it into B2 like this: =COUNTA(CHOOSECOLS((UNIQUE(HSTACK($A$2:$A$1001;$D$2:$D$1000;$H$2:$H$1000;$I$2:$I$1000);FALSE));1)) (took it down to row 1000)

and it returns "6", which makes no sense to me, as there are only 2 variations of "name1" in those rows

likewise, it should return "1" on row B5 and B6
i errored, i didnot filter for the name.
here it is updated in a LET function:

mr excel questions 34.xlsm
ABDHIJ
1Identifiernumberwhateverfinal datenumber
2name1325-01-202325-01-20241000000
3name1325-03-202325-01-20241000000D3 <> D2
4name1325-03-202325-01-202450000<< text in I
jyggalag
Cell Formulas
RangeFormula
B2:B4B2=LET(name,$A2,names,$A$2:$A$4,colD,$D$2:$D$4,colH,$H$2:$H$4,colI,$I$2:$I$4, colstack,HSTACK(names,colD,colH,colI),filtcolstack, FILTER(colstack,names=name,""),uniqitems,UNIQUE(filtcolstack,FALSE),uniqnames,CHOOSECOLS(uniqitems,1),countuniqnames,COUNTA(uniqnames),countuniqnames)
 
Upvote 1
Solution
i errored, i didnot filter for the name.
here it is updated in a LET function:

mr excel questions 34.xlsm
ABDHIJ
1Identifiernumberwhateverfinal datenumber
2name1325-01-202325-01-20241000000
3name1325-03-202325-01-20241000000D3 <> D2
4name1325-03-202325-01-202450000<< text in I
jyggalag
Cell Formulas
RangeFormula
B2:B4B2=LET(name,$A2,names,$A$2:$A$4,colD,$D$2:$D$4,colH,$H$2:$H$4,colI,$I$2:$I$4, colstack,HSTACK(names,colD,colH,colI),filtcolstack, FILTER(colstack,names=name,""),uniqitems,UNIQUE(filtcolstack,FALSE),uniqnames,CHOOSECOLS(uniqitems,1),countuniqnames,COUNTA(uniqnames),countuniqnames)
this formula is absolutely insane AND IT WORKS!!!

you are my savior awoohaw! that's a crazyyy formula I love it haha

thank you so much! you have no idea how much this helps me, really appreciate it <3 :)
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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