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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
kirwanm1
Frequent Visitor

Distinct Count based on max value

Hey Everyone,


I'm having a little trouble with filtering by the maximum value of a month no. and wondering if anyone knows where I'm going wrong.

 

I have the following formula

Charities (Monthly) = CALCULATE(DISTINCTCOUNT(donation_event[recipient_id]), donation_event[Week No.]=max(donation_event[Week No.]))

 

Its just to get a distinct count of the recipients when the week no. is equal to the max value for the week no column and I am getting the following error.

 

"A function 'MAX' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

Not sure where I'm going wrong as the below works fine too.

 

Charities (Monthly) = CALCULATE(DISTINCTCOUNT(donation_event[recipient_id]), donation_event[Week No.]=20))


Thanks

 

 

 

 

 

 

1 ACCEPTED SOLUTION
prateekraina
Memorable Member
Memorable Member

Edited

Hi @kirwanm1,

 

Try this DAX:

Charities (Monthly) = CALCULATE(DISTINCTCOUNT(donation_event[recipient_id]), FILTER(donation_event,donation_event[Week No.]=max(donation_event[Week No.])))


There might some braces missing, just correct that, it should work.

Thanks !!!

View solution in original post

4 REPLIES 4
prateekraina
Memorable Member
Memorable Member

Edited

Hi @kirwanm1,

 

Try this DAX:

Charities (Monthly) = CALCULATE(DISTINCTCOUNT(donation_event[recipient_id]), FILTER(donation_event,donation_event[Week No.]=max(donation_event[Week No.])))


There might some braces missing, just correct that, it should work.

Thanks !!!

Thanks. That works perfectly!


Welcome @kirwanm1 
Kindly like the post if you think it has solved your problem 🙂

kirwanm1
Frequent Visitor

Table Example
Shop a     |    6

Shop a     |    6

Shop a     |    7

Shop a     |    7

Shop b     |    5

Shop b     |    5

Shop b     |    6

Shop b     |    6

Shop c     |    5

Shop c     |    7

Shop c     |    7

Shop c     |    7

Shop c returns 3

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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