Avatar of Ian Bell
Ian Bell
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Establish identical Values within an index range

Hi,
I would like a formula to establish identical values within an index range.
Please see attached
Many thanks
Ian
identical-values-within-range.xlsx
SpreadsheetsMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Ian Bell

8/22/2022 - Mon
SOLUTION
Subodh Tiwari (Neeraj)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Saqib Husain

Another formula

=--(SUMPRODUCT(--(A2:A15=A2))<>SUMPRODUCT((A2:A15=A2)*(B2:B15=B2)))
Subodh Tiwari (Neeraj)

To counter the Saqib's formula, here is the more elegant formula... Lol
=--(COUNTIF($A$2:$A$15,A2)<>COUNTIFS($A$2:$A$15,A2,$B$2:$B$15,B2))

Open in new window

and copy it down. :)
Ian Bell

ASKER
They all take a long time to calculate
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Saqib Husain

What is the maximum number of entries in any one index set?
Ian Bell

ASKER
40
Subodh Tiwari (Neeraj)

And how many rows of data in there?
After copying the formula down the rows, you can copy the formula range and paste it back as values so that the formulas don't recalculate every time.
Or you can use VBA to place the formula.
In the attached, place the data from your original file in the column A and B starting from Row2 and click the button called "Place Formula" and see if it works faster than manually placing the formula.
identical-values-within-range.xlsm
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Saqib Husain

Try this formula

=--(COUNTIF(A2:A51,A2)<>COUNTIFS(A2:A51,A2,B2:B51,B2))
Subodh Tiwari (Neeraj)

@Saqib
The formula you posted is the same I posted here. What I am missing here?
Saqib Husain

Subodh, I have removed the absolute marks $

But that formula would fail in some scenarios. So a new formula.

=--(COUNTIF(OFFSET(A2,MAX(-50,-ROW()+2),0,100),A2)<>COUNTIFS(OFFSET(A2,MAX(-50,-ROW()+2),0,100),A2,OFFSET(B2,MAX(-50,-ROW()+2),0,100),B2))
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Ian Bell

ASKER
Here is a formula using the indirect condition.
In fact the rows and columns are correct so a matter of inserting your new formula.
DC and DD are the F & G columns I referred to in my example.
JR being the Index column

=IF(JR14="","",IF(JR14=JR13,CS13,SUM(INDEX((INDIRECT("$JR"&DC14&":$JR"&DD14)=JR14)*(INDIRECT("$A"&DC14&":$A"&DD14)),0))))
ASKER CERTIFIED SOLUTION
Saqib Husain

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Rob Henson

Applying a bit of logic, if all values in an index range are the same they have to be the same as the Average for the index range.

Therefore, you can use:
=IF(B2=SUMIFS(B:B,A:A,A2)/COUNTIFS(A:A,A2),0,1)

For later versions of Excel:
=IF(B2=AVERAGEIFS(B:B,A:A,A2),0,1)
SOLUTION
Rob Henson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ian Bell

ASKER
Thank you guys. I'd be lost without you :)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ian Bell

ASKER
Hi guys,
I was trying out Rob's simple solution and worked well and calculated in less than a couple of minutes, which is fast
for this 160,000 row spreadsheet

I will work with this one for now but will also run the other formulas and will claim them all as a solution if that is permissible.
Thank You Rob, Saqib and Neeraj
Ian
Rob Henson

Thanks Ian, glad it worked well.
Saqib Husain

Are you sure that is is Rob's solution which is fastest?

Besides, you accepted mine.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Ian Bell

ASKER
There's not a lot of difference in speed between some of the formulas.
Saqib Husain

That can't be right. I repeated the given data for more than 160,000 rows and the formula gave the results in only a second or two.
Ian Bell

ASKER
Which one of your formulas did you use ?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Saqib Husain

The accepted one
Ian Bell

ASKER
I will have to check this later as I need to go out.
Ian Bell

ASKER
Hi Saqib,
Seems I selected wrong solution.
I need the formula to return either 1 or 0
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Saqib Husain

I am leaving for home. I am going to send a file showing comparisons. You can then see the difference.
Ian Bell

ASKER
Thanks Saqib very kind of you..
Ian Bell

ASKER
Saqib,
I have found an alternative method to arrive at the conclusion without the use of
this formula. I'm understanding more and more about this monster of a spreadsheet
Apologies for inconvenience.
Ian
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Saqib Husain

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ian Bell

ASKER
okay thanks Saqib I'll check it out.
Ian Bell

ASKER
I finally got onto your formula having been away from here yesterday.
I tried your end col formula and it certainly was fast as only took a few
seconds to calculate. I'm off for a long walk and when I get back will
check out your other formula.
Thanks again Saqib your effort was certainly worthwhile from my point of view
Ian
Ian Bell

ASKER
Just back from my usual 2 hour Friday walk with my neighbour and tested your formula in G column.
Both work perfectly and came up with identical results and both calculated at a fast speed of a few seconds for 170k rows.
Thanks a million Saqib.
Ian
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Ian Bell

ASKER
A big thank you to all you guys who submitted solutions. They worked well, some calculated
quicker than others.