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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Dax count rows for a group for the last date

Hi,

I want to count distinct Numbers column if the Event Code = CANCEL for last Entry Date Time Local  per Number.

for example, I want below Number to be counted as 1 because the Event Code = CANCEL  is the last Entry Date Time Local 

 

2022-05-11_9-49-57.png

 

but below should not be counted because the Event Code = CANCEL  is not the last Entry Date Time Local :

2022-05-11_9-41-51.png

can you please help.

3 REPLIES 3
isabella
Microsoft Employee
Microsoft Employee

Hi @Anonymous 

I did a local test ,you can take a reference ,here is my steps:

1.create a measure to calculate the max entry date per number

  max entry date per number = CALCULATE(MAX('Table'[Entry Date Time Local]),ALLEXCEPT('Table','Table'[Number]))

 

isabella_0-1652344544120.png

 

2.create a measure to sum the distinct number that satisfy the condition

 

distinct count number = SUMX('Table',IF([max entry date per number]=[Entry Date Time Local] && [Event Code]="CANCEL",1,0))

 

isabella_1-1652344544122.png

 

 

isabella_2-1652344544124.png

 

Best Regards,

Community Support Team _Isabella

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Ashish_Mathur ,

 

I can't share the PBI file because I use tabular model as the data source.

I want to see the result in a matix by location or date.

Ashish_Mathur
Super User
Super User

Hi,

Do you want to see the result in a card visual?  Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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