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

View all the Fabric Data Days sessions on demand. View schedule

Reply
TSantoro99
New Member

Countif with multiple criteria - DAX

Hello, 

 

I am looking for some assistance in writing a DAX formula which will act as a countif with multiple criteria. I have the excel version here with some simplified data for an example: 

 

 

I am looking to add a column to my data table that will count the number of times a unique combination of ID and Week appear. 

 

My true data set is all in one table (StudentRelatedServicesDetail) and I would need to count number of times that a student's service (RelatedServiceID) is scheduled during a given week (Either: ServiceDate or YearAndWeek). 

 

 

Any assistance that can be provided would be much appreciated! 

 

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @TSantoro99,

 

You can create a column by concatenating the columns id and week with M code in your Query Editor, like this:

 

 

 #"Added Custom" = Table.AddColumn(#"Previous step", "Concatenated", each [id]&"_"&[Week])



and then using DAX create a column with the count of occurrences of the concatenated values, using this formula:

 

 

Count_occurence =
COUNTX (
FILTER ( Table; EARLIER ( Table[Concatenated] ) = Table[Concatenated] );
Table[Concatenated]
)

 

Regards.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @TSantoro99,

 

You can create a column by concatenating the columns id and week with M code in your Query Editor, like this:

 

 

 #"Added Custom" = Table.AddColumn(#"Previous step", "Concatenated", each [id]&"_"&[Week])



and then using DAX create a column with the count of occurrences of the concatenated values, using this formula:

 

 

Count_occurence =
COUNTX (
FILTER ( Table; EARLIER ( Table[Concatenated] ) = Table[Concatenated] );
Table[Concatenated]
)

 

Regards.

@Anonymous - Thank you so much Felipe! You have saved me many hours of hair-pulling and frustration trying to get that to work! It looks excellent and is exactly what I needed.  Smiley Very Happy Many, many, thanks! 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors