Countif problem

Nabei

New Member
Joined
Sep 3, 2014
Messages
7
Hi there

currently facing a countif problem. Below is my sample data

45001245-1
45001245-2
45001245-3

45001248-1
45001248-2

For the duplicate data i.e. 45001245-1, -2, -3, i would like to set the data ending with -1 to value 1 and the rest to value 0

Currently using this formula
=IF(Countif(A$2:A$15,A2)=1,1,0) without the implementation of the dashes as it wouldnt work if the data has dashes.

Any help is appreciated.
Thanks in advance
 
Set a count for the data such that those that ends with "-1" (45001246-1) return a value of 1, and the rest (45001246-2, 45001246-3, 45001246-3) return a value of 0. hope that clarifies things

Are you then going to sum those 1 and 0's to arrive at a count?
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
but you said there will be cases without "-"; and the sequence may not be in ascending order...
could you pls state your requirements in one go?

Set a count for the data such that those that ends with "-1" (45001246-1) return a value of 1, and the rest (45001246-2, 45001246-3, 45001246-3) return a value of 0. hope that clarifies things
 
Upvote 0
but you said there will be cases without "-"; and the sequence may not be in ascending order...
could you pls state your requirements in one go?

sorry,

1.For cases without "-" returns a value of 1
2.cases with "-", those that ends with "-1" returns a value of 1, others ("-2", "-3") return value of 0
3.Cases with "-" may not necessarily be in ascending order, "-2" may appear first and "-1" might appear several columns later.
4.duplicates (45001234-1, 45001234-2) may or may not be grouped together

apologies for not explaining in detail. Happened to find out several problems halfway trying out different formulas
 
Upvote 0
Just to return the value 1 or 0. Not going to sum them up


XY
45001245-11
45001245-20
45001245-30
45001248-11
45001248-20

<COLGROUP><COL style="WIDTH: 99pt; mso-width-source: userset; mso-width-alt: 4693" width=132><COL style="WIDTH: 48pt" width=64><TBODY>
</TBODY>

B2, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IF($A2="","",IF(1-ISNUMBER(MATCH(LEFT($A2,FIND("-",$A2&"-")-1),
  LEFT($A$1:A1,FIND("-",$A$1:A1&"-")-1),0)),IF(RIGHT($A2,2)+0=-1,1,0),0))
 
Upvote 0
seems that the suffice -1, -2, -3, is already an indication of duplicates, isn't it?

If that's the case, something like the following may work:

45001245-11
45001245-20
45001245-30
450012341
450012351
45001248-20
45001248-11
45001245-40

<tbody>
</tbody>

In B2
=IF(ISERROR(FIND("-",A1)),1,IF(RIGHT(A1,2)="-1",1,0))

Not sure if this suits your case.



sorry,

1.For cases without "-" returns a value of 1
2.cases with "-", those that ends with "-1" returns a value of 1, others ("-2", "-3") return value of 0
3.Cases with "-" may not necessarily be in ascending order, "-2" may appear first and "-1" might appear several columns later.
4.duplicates (45001234-1, 45001234-2) may or may not be grouped together

apologies for not explaining in detail. Happened to find out several problems halfway trying out different formulas
 
Last edited:
Upvote 0
seems that the suffice -1, -2, -3, is already an indication of duplicates, isn't it?

If that's the case, something like the following may work:

45001245-11
45001245-20
45001245-30
450012341
450012351
45001248-20
45001248-11
45001245-40

<tbody>
</tbody>

In B2
=IF(ISERROR(FIND("-",A1)),1,IF(RIGHT(A1,2)="-1",1,0))

Not sure if this suits your case.


works like a charm! Thank you so much! Something new learnt today :)
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,852
Members
449,096
Latest member
Erald

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