Forum Discussion
Catman
2 years agoFrequent Visitor
Count for ContractID
Hi,
I am having trouble counting the number of occurences for an attribute, in this case ContractID & StartDate. Basically I need to count how many distinct Start Date for each ContractID and show the result in the same table.
| Contract ID | Invoice ID | Start Date | Invoice Sales | Count |
| 2024001 | AA111 | 5/2/2024 | 1000 | 3 |
| 2024001 | AA112 | 5/2/2025 | 1000 | 3 |
| 2024001 | AA113 | 5/2/2026 | 1000 | 3 |
| 2024001 | AA114 | 5/2/2026 | -1000 | 3 |
| 2024001 | AA115 | 5/2/2026 | 1000 | 3 |
| 2024002 | AA116 | 5/9/2024 | 1000 | 2 |
| 2024002 | AA117 | 5/9/2025 | 1000 | 2 |
| 2024003 | AA118 | 5/5/2024 | 1000 | 1 |
| 2024004 | AA119 | 5/10/2024 | 1000 | 1 |
| 2024005 | AA120 | 5/11/2024 | 1000 | 1 |
| 2024006 | AA121 | 5/15/2024 | 1000 | 2 |
| 2024006 | AA122 | 5/15/2025 | 1000 | 2 |
I have tried using the following: countrows(summarize('Table1', 'Table1'[ContractID]))
And the result is always 1 instead of my expected result (see below)
I think this is just a missing link to aggregate the count to the ContractID. Hope someone can help.
Thanks,
Cat
Hi Catman - Create a New Column as below:
DistinctStartDateCount =CALCULATE(COUNTROWS(DISTINCT('countff'[Start Date])),ALLEXCEPT('countff', 'countff'[Contract ID]))output FYR:It works, please check
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
2 Replies
- rajendraongole1Super User
Hi Catman - Create a New Column as below:
DistinctStartDateCount =CALCULATE(COUNTROWS(DISTINCT('countff'[Start Date])),ALLEXCEPT('countff', 'countff'[Contract ID]))output FYR:It works, please check
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!! - CatmanFrequent Visitor
Thank you so much, it is working as expected now.