How can I count distinct values under a same month?
Hi everyone,
I currently have a data set for which I would like to count all unique values that are under a same month and a same year. For example, the following table shows two duplicate values (TR ID's) on two different dates. In this case I would only like to count the unique TR ID's for the month of August, 2020 (which should be 6):
I have been trying to use the =COUNT(DISTINCT(COLLECT(.....))) expression, however, it returns "1", when it should count "6".
Thanks in advance,
Carolina
Answers
-
Try something like this...
=COUNT(DISTINCT(COLLECT([TR ID]:[TR ID], Date:Date, AND(IFERROR(MONTH(@cell), 0) = 8, IFERROR(YEAR(@cell), 0) = 2020))
-
Hi Paul, I tried re-creating this formula for my purposes and I'm getting an "#unparseable" when I adjust the equation for my needs. The following formula should return "2":
=COUNT(DISTINCT(COLLECT([Patient number]1:[Patient number]3, [Dosing date]1:[Dosing date]3, AND(IFERROR(MONTH(@row),0) = 1, IFERROR(YEAR(@row),0) = 2022))))
Can you point out what I'm doing wrong? Thank you!
-
Hi @AHANSON
Instead of using @row inside of your MONTH and YEAR functions, you'll want to use @cell.
Try:
=COUNT(DISTINCT(COLLECT([Patient number]1:[Patient number]3, [Dosing date]1:[Dosing date]3, AND(IFERROR(MONTH(@cell),0) = 1, IFERROR(YEAR(@cell),0) = 2022))))
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 439 Global Discussions
- 138 Industry Talk
- 471 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!