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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
yve214
Helper III
Helper III

Help with distinct count with date conditions

Hi there,

 

IDEmp_IDIntervalEffective_DateScore
2100108/26/2020

3.3

6100201/1/20222.0
31001311/20/20203.5
5100152/1/20214.1
61002509/05/20215.0

 

 

I am trying to "count the emp IDs at interval 5, making sure the dates at that interval of 5 is greater than the dates at interval 0 like (effective date at the 5 interval > the effective date at interval 0). please can someone help with this?

 

Here is how i approached it. I created two date measures for both interval 0 and interval 5. then I did an

 

if((date_at_interval_5) > (date_at_interval_0) && table[interval] = 5, distinctcount(table[emp_ID]). But i keep getting blank.

 

Results:

In this case, I should only expect a return of 1 count for emp 1001 since they have a 5 month interval with a date greater than their 0 interval. Since 1002 had a 5 interval of an earlier date 09/05/2021 at 5 < 1/1/2022 at 0 , this should be excluded.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@yve214 , Create a measure like

 


measure =
var _max0 = maxx(filter(allselected(Table), Table[Emp_id] = max(Table[Emp_id]) && Table[Interval] =0),Table[Effective_Date])
var _max5 = maxx(filter(allselected(Table), Table[Emp_id] = max(Table[Emp_id]) && Table[Interval] =5),Table[Effective_Date])
return
calculate(distinctcount(table[emp_ID]), filter(Table, Table[Interval] =5 && _max5>_max0))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@yve214 , Create a measure like

 


measure =
var _max0 = maxx(filter(allselected(Table), Table[Emp_id] = max(Table[Emp_id]) && Table[Interval] =0),Table[Effective_Date])
var _max5 = maxx(filter(allselected(Table), Table[Emp_id] = max(Table[Emp_id]) && Table[Interval] =5),Table[Effective_Date])
return
calculate(distinctcount(table[emp_ID]), filter(Table, Table[Interval] =5 && _max5>_max0))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Thank you very much. I was able to get the numbers in a row context. Please how can i get this number in a card?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.