Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Catman
Frequent 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 IDInvoice IDStart DateInvoice SalesCount
2024001AA1115/2/202410003
2024001AA1125/2/202510003
2024001AA1135/2/202610003
2024001AA1145/2/2026-10003
2024001AA1155/2/202610003
2024002AA1165/9/202410002
2024002AA1175/9/202510002
2024003AA1185/5/202410001
2024004AA1195/10/202410001
2024005AA1205/11/202410001
2024006AA1215/15/202410002
2024006AA1225/15/202510002

 

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

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @Catman - Create a New Column as below:

 

DistinctStartDateCount =
CALCULATE(
    COUNTROWS(
        DISTINCT('countff'[Start Date])
    ),
    ALLEXCEPT('countff', 'countff'[Contract ID])
)
 
output FYR:
 
rajendraongole1_0-1720079572580.png

 

 

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!!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
Catman
Frequent Visitor

Thank you so much, it is working as expected now. 

rajendraongole1
Super User
Super User

Hi @Catman - Create a New Column as below:

 

DistinctStartDateCount =
CALCULATE(
    COUNTROWS(
        DISTINCT('countff'[Start Date])
    ),
    ALLEXCEPT('countff', 'countff'[Contract ID])
)
 
output FYR:
 
rajendraongole1_0-1720079572580.png

 

 

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!!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.