Hello, I wanted to know if its possible to use the "count if function" (or any other function) with more than one criteria.
When is use the [COUNTIF($A$2:$A2,A2)] formula in column C, I'm able to obtain the number of times ID (column A)is present in my data.
I would like to know if there is a way to use 2 criterias (ID and LACT) and obtain something like I have in column D. Were the formula would account for both ID and LACT. I'm working with really large datasets and it would be really helpful to be able to sort my data easily.
Thanks
ID LACT COUNT ID ID and LACT as criteria
974 4 1 1
974 4 2 1
974 4 3 1
974 4 4 1
986 5 1 1
986 5 2 1
986 5 3 1
986 5 4 1
986 5 5 1
986 5 6 1
986 5 7 1
986 5 8 1
986 5 10 1
986 6 14 2
986 6 15 2
989 4 1 1
989 4 2 1
989 4 3 1
989 5 4 2
989 5 5 2
989 5 6 2
989 5 7 2
989 5 8 2
989 5 9 2
989 5 11 2
Hi
Try this.
=SUMPRODUCT(($A$1:$A$20=A1)*($B$1:$B$20=B1))
Hope to helps you.
Regards
Fotis.
I am proud that i am Greek.
Just to know every one.We Greeks, we are nοt proud of our politicians. Υou?
Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.
Please,mark your thread [SOLVED] if you received your answer.
My Avadar picture, is from Athens Acropolis.
http://www.theacropolismuseum.gr
http://www.visitgreece.gr/
Thank you for your help Fotis. I will play a little with this formula and let you know.
OK! I'll wait![]()
Regards
Fotis.
I am proud that i am Greek.
Just to know every one.We Greeks, we are nοt proud of our politicians. Υou?
Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.
Please,mark your thread [SOLVED] if you received your answer.
My Avadar picture, is from Athens Acropolis.
http://www.theacropolismuseum.gr
http://www.visitgreece.gr/
With Excel 2007, you can use COUNTIFS too...
=COUNTIFS($A$2:$A2,$A2,$B$2:$B2,$B2)
copied down
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Hello guys,
Thank you very much for your help. I have been trying with both formulas and none of them seem to be working as I expected:
Probably I didn't make a good job explaining what I wanted. But what I would like to get with the formula is something like I present below (What I would like). Basically I would like to know if there is a formula that can account for both ID and LACT and give me a value. For example: ID 974 has LACT values of 4 for all the observations, therefore I would like to get all 1 (LACT level for that ID didn't change). For ID 986, notice that it has 2 levels of LACT 5 and 6. What I would like for this particular case is that the formula label the all the combinations of ID 986 and LACT 5 as 1 and all the combinations of ID 986 and LACT 6 as 2. Similarly for ID 989 LACT 4 get 1 and for the combination of ID 989 LACT 2 get 2. Hope this clarifies what I'm looking for.
Thanks again for your help
ID LACT COUNT ID What I would like =COUNTIFS($A$2:$A2,$A2,$B$2:$B2,$B2)
974 4 1 1 1
974 4 2 1 2
974 4 3 1 3
974 4 4 1 4
986 5 5 1 1
986 5 6 1 2
986 5 7 1 3
986 5 8 1 4
986 5 9 1 5
986 5 10 1 6
986 5 11 1 7
986 5 12 1 8
986 5 13 1 9
986 6 14 2 1
986 6 15 2 2
989 4 1 1 1
989 4 2 1 2
989 4 3 1 3
989 5 4 2 1
989 5 5 2 2
989 5 6 2 3
989 5 7 2 4
989 5 8 2 5
989 5 9 2 6
989 5 10 2 7
Here is a better picture for clarificationCapture1.JPG
If everything is grouped as per your attachment, then assuming data starts in A2 and B2, try in new column:
=IF(A2<>A1,1,IF(B2=B1,C1,C1+1))
copied down.
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Thank you very much for your help. I have been trying with both formulas and none of them seem to be working as I expected.
Probably I didn't make a good job explaining what I wanted. But what I would like to get with the formula is something like I present below (in the What I would like column). Basically I would like to know if there is a formula that can account for both ID (A2) and LACT (B2) and give me a value. For example: ID 974 has LACT values of 4 for all the observations, therefore I would like to be able to get all 1 (LACT level for that ID didn't change). For ID 986, notice that it has 2 levels of LACT 5 and 6. What I would like for this particular case is that the formula label the all the combinations of ID 986 and LACT 5 as 1 and all the combinations of ID 986 and LACT 6 as 2. Similarly for ID 989 LACT 4 get 1 and for the combination of ID 989 LACT 2 get 2. Hope this clarifies what I'm looking for. Please take a look at the attached picture for clarification. In the picture you will see the numbers that I got after introducing the formula that you gave me. Excel formula.jpg
Thanks again for you help
To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook. Don't upload a picture when you have a workbook question. None of us is inclined to recreate your data. Upload the workbook and manually add an 'after' situation so that we can see what you expect. In addition clearly explain how you get the results..
To attach a file to your post, you need to be using the main 'New Post' or 'New Thread' page and not 'Quick Reply'.
To use the main 'New Post' page, click the 'Post Reply' button in the relevant thread.
On this page, below the message box, you will find a button labelled 'Manage Attachments'.
Clicking this button will open a new window for uploading attachments.
You can upload an attachment either from your computer or from another URL by using the appropriate box on this page.
Alternatively you can click the Attachment Icon to open this page.
To upload a file from your computer, click the 'Browse' button and locate the file.
To upload a file from another URL, enter the full URL for the file in the second box on this page.
Once you have completed one of the boxes, click 'Upload'.
Once the upload is completed the file name will appear below the input boxes in this window.
You can then close the window to return to the new post screen.
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks