MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 13th, 2002, 06:12 AM   #1
rogerm
Board Regular
 
Join Date: May 2002
Location: Bristol, England
Posts: 53
Default

Could anyone help me with the following:

I have three colums of data.

In the first colum I have names
The second Column I have week numbers
And the 3rd column I have dates

I have to report how many dates in ta given week number reports were submitted by each person.

The problem is that on some days more than one report has been submitted so when I count using an array formula such as

=SUM((A2:A10="Name")*(B2:B10="week number")
*C2:C10)
The result is wrong.

I need to count the number of distinct (unique) dates in the date column (c)for a given person on a given date

so I need a combination of

=SUM((A2:A10="Name")*(B2:B10="week number")
to select the ranges together with

=SUM(N(FREQUENCY(C1:A10,C1:C10)>0))

but I'm not sure how to put them together.

to count the unique entries for the range.

Or perhaps there is an easier way or another function I could use.

Any suggestions would be gratefully received.


rogerm is offline   Reply With Quote
Old May 13th, 2002, 07:02 AM   #2
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Array-enter:

=SUM(IF((A2:A5=E1)*(B2:B5=F1),1/COUNTIF(C2:C5,C2:C5)))

where E1 houses a name and F1 a week number.

To array-enter a formula, hit control+shift+enter at the same time, not just enter.

Aladin
Aladin Akyurek is offline   Reply With Quote
Old May 13th, 2002, 07:17 AM   #3
Shoaib
New Member
 
Join Date: Feb 2002
Posts: 6
Default

Why dont you use a pivot table?

Name and week in row area, date in data field
will give you the info in an instant

Shoaib is offline   Reply With Quote
Old May 15th, 2002, 03:51 PM   #4
megnin
Board Regular
 
megnin's Avatar
 
Join Date: Feb 2002
Location: Fort Lauderdale
Posts: 338
Default

I have a similar problem. I tried it with a pivit table. It did not give me unique "dates", but counted every occurance.
How do you tell a pivit table to only count unique occurances?
"Count of" counts them all.

megnin@nortelnetworks.com
megnin is offline   Reply With Quote
Old May 16th, 2002, 01:52 AM   #5
rogerm
Board Regular
 
Join Date: May 2002
Location: Bristol, England
Posts: 53
Default

The first solution didn't seem to work - It still counted all the values even though I formatted the dates/time as just a short date. It perhaps only works on whol numbers.

I finally solved the problem using some code and a pivot table. (Thanks for suggesting this I hadnt used pivot tables before)

As the du-plicates when they occurred were appearing one after the other I used the following code to replace all the duplicate entries, except the first, in each group with the string "----". To use this code, first select the cells (in one column) that you want to change, then run the procedure.

Sub FixDuplicateRows()
Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value Then
Cells(RowNdx, ColNum).Value = "----"
End If
Next RowNdx
End Sub

(I got this code from http://www.cpearson.com/excel/duplicat.htm>

This formed a column with just the unique dates for each week. I then used this column in the pivot table which counted the dates for me.
rogerm is offline   Reply With Quote
Old May 16th, 2002, 03:44 AM   #6
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default


On 2002-05-16 00:52, rogerm wrote:
The first solution didn't seem to work - It still counted all the values even though I formatted the dates/time as just a short date. It perhaps only works on whol numbers.


Here is how:

Microsoft Excel - aaMultCondUniqCount RogerM.xls_______________Running: xl2000 : OS = Windows (32-bit) NT 5.00
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp
G2==SUM(IF((A2:A5=E2)*(B2:B5=F2),1/COUNTIF(C2:C5,C2:C5)))
*ABCDEFG
1NameWeek NumDate****
2ann:alert('=WEEKNUM(C2)')>11/2/2002*ann1:alert('{=SUM(IF((A2:A5=E2)*(B2:B5=F2),1/COUNTIF(C2:C5,C2:C5)))}')>1
3ann:alert('=WEEKNUM(C3)')>11/2/2002****
4bob:alert('=WEEKNUM(C4)')>11/4/2002****
5fred:alert('=WEEKNUM(C5)')>21/7/2002****
Sheet1

To see the formula in the cells just click on the cells hyperlink

The above image was automatically generated by [HtmlMaker V1.22]
If you want this code, click here and Colo will email the file to you.
This code was graciously allowed to be modified: by Ivan F Moala All credit to Colo


Aladin Akyurek is offline   Reply With Quote
Old May 16th, 2002, 10:31 AM   #7
megnin
Board Regular
 
megnin's Avatar
 
Join Date: Feb 2002
Location: Fort Lauderdale
Posts: 338
Default

My result using the above formul is a fraction. The count of unique items could not be a fraction. I have a worksheet with 42000 rows. I get 901.8174 as the result.

Order#........Color........Shape
11A Red Circle
11A Red Square
11A Blue Square
12B Blue Triangle
12B Red Rectangle
13C Green Circle
13C Green Triangle

I need a formula that will return the number of unique Order #s that contain only red circles or squares and blue circles and squares. The result from the above data would be 1. Only 11A..Red..Circle is unique Order # matching criteria.

I do not think it can be done with a single formula.

(Advanced Filters do not return unique numbers, they return every matching Order #)

Thanks for any assistance.
megnin is offline   Reply With Quote
Old May 16th, 2002, 11:00 AM   #8
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-05-16 09:31, megnin wrote:
My result using the above formul is a fraction. The count of unique items could not be a fraction. I have a worksheet with 42000 rows. I get 901.8174 as the result.

Order#........Color........Shape
11A Red Circle
11A Red Square
11A Blue Square
12B Blue Triangle
12B Red Rectangle
13C Green Circle
13C Green Triangle

I need a formula that will return the number of unique Order #s that contain only red circles or squares and blue circles and squares. The result from the above data would be 1. Only 11A..Red..Circle is unique Order # matching criteria.

I do not think it can be done with a single formula.

(Advanced Filters do not return unique numbers, they return every matching Order #)

Thanks for any assistance.
Megnin,

The above formula is appropriate in Rogerm's case that requires AND'ing. Your case requires OR'ing (and AND'ing) for which it will not work. Becasuse you have a huge amount data, a single array formula (if there is one0 would be performance-degrading. That's reason why I looked and suggested a different solution for your case in a different thread.

Aladin
Aladin Akyurek is offline   Reply With Quote
Old Oct 14th, 2003, 05:31 PM   #9
Cosmos75
Board Regular
 
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
Default Re: Counting unique entries with two given conditions

******** ******************** ************************************************************************>
Microsoft Excel - Book3___Running: xl2000 : OS = Windows Windows 2000
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
=

A
B
C
D
1
XYNumber or letters where Y > 5 = 6
2
a1
3
a2
4
a6
5
b6
6
b0
7
c1
8
c2
9
c4
10
d1
11
d2
12
d3
13
d1
14
e6
15
e7
16
e1
17
f8
18
f9
19
g1
20
g2
21
h3
22
h6
23
I5
24
i6
25
j1
26
j2
Sheet1

[HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.

How can I count the number of Unique X-Values that have at least one Y-value greater than 5?
Cosmos75 is offline   Reply With Quote
Old Oct 14th, 2003, 06:31 PM   #10
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default Re: Counting unique entries with two given conditions

Quote:
Originally Posted by Cosmos75
...
How can I count the number of Unique X-Values that have at least one Y-value greater than 5?
=COUNTDIFF(IF(B2:B26>5,A2:A26))-1

which you need to confirm with control+shift+enter, not just with enter.

Requires the morefunc add-in.
__________________
Microsoft MVP - Excel
Aladin Akyurek is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 09:43 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes