Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count distinct orders with condition

Status
Not open for further replies.

flaviooooo

Programmer
Feb 24, 2003
496
FR
Hey,

I have an excel like this:

Week Order1 Order2 Order3
1 123456 123457 123457 01
2 123458 123459
2 123460


Now I would like to count the amount of distinct orders in each row. Watch out, an distinct order is only the first 6 digits. So in Week 1 for example 123457 and 123457 01 are actually the same order!

The result I would like is:
Week Order1 Order2 Order3 COUNT
1 123456 123457 123457 01 2
2 123458 123459 2
2 123460 1


Can this be done?

Thanks in advance
 
Will the orders be continious? i.e. will there never be

Order1 Order2
123456 123460

If so, you can use the formula below:

Code:
=LEFT(MAX(B1:E1),6)-LEFT(B1,6)+1

If not, it's back to the drawing board, I guess :)

Cheers,

Roel
 
Hey Roel,

thanks for the response, but unfortunately it can occur that some orders are 'left out'...

Back to the drawing board indeed ;-)
 
assume the following series:

123456,123457,123460,123462,123470,123471,123471 01

Would your expected the count be 6?

If so, I believe the following is what you're looking for:

Code:
=SUM(--(VALUE(LEFT(B1:G1,6))-VALUE(LEFT(A1:F1,6))>0))+1

This will need to be entered as an array formula (ctrl-shft-enter)


Cheers,

Roel

 
Hey Roel,

thanks again

Unfortunately I get an error #VALUE!, which I think is due to empty columns?

 
Hi,

indeed, empty cells in the referenced range will result in #VALUE.

try this instead:

Code:
=SUM(--(VALUE(LEFT(IF(ISBLANK(RC[-7]:RC[-2]),0,RC[-7]:RC[-2]),6))-VALUE(LEFT(IF(ISBLANK(RC[-8]:RC[-3]),0,RC[-8]:RC[-3]),6))>0))+1

(remember to enter it as array-formula - ctrl+shft+enter)

Cheers,

Roel

 
sorry, still had my R1C1 on.

Code:
=SUM(--(VALUE(LEFT(IF(ISBLANK(B1:G1),0,B1:G1),6))-VALUE(LEFT(IF(ISBLANK(A1:F1),0,A1:F1),6))>0))+1

Cheers,

Roel
 
Hi flavi00000:

I understand that your order entries are always going to be either 6 digits or 6 digits a space and then some additional characters. If do, then ...

ytek-tips-thread68-1407129a.gif


Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top