Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
I am new to power bi and i need to count the number of times that a employee has the same issue code in less than 50 days.
Employee | Code | Date
01 | 101 | mm/dd/yyyy
02 | 101 | mm/dd/yyyy
03 | 101 | mm/dd/yyyy
02 | 101 | mm/dd/yyyy
01 | 100 | mm/dd/yyyy
03 | 101 | mm/dd/yyyy
03 | 102 | mm/dd/yyyy
I tried to get the days using datediff but im not so sure how to implement the conditionals to count that.
Solved! Go to Solution.
Hi, @Compacted
As you said, if your data sets are less than 50 days, you can count directly.
1. Calculated column
Count =
CALCULATE (
COUNT ( 'Table'[ Code ] ),
FILTER (
'Table',
'Table'[Employee ] = EARLIER ( 'Table'[Employee ] )
&& 'Table'[ Code ] = EARLIER ( 'Table'[ Code ] )
)
)
2. Measure
Measure =
CALCULATE (
COUNT ( 'Table'[ Code ] ),
FILTER (
ALL ( 'Table' ),
'Table'[Employee ] = MAX ( 'Table'[Employee ] )
&& 'Table'[ Code ] = MAX ( 'Table'[ Code ] )
)
)
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Compacted
As you said, if your data sets are less than 50 days, you can count directly.
1. Calculated column
Count =
CALCULATE (
COUNT ( 'Table'[ Code ] ),
FILTER (
'Table',
'Table'[Employee ] = EARLIER ( 'Table'[Employee ] )
&& 'Table'[ Code ] = EARLIER ( 'Table'[ Code ] )
)
)
2. Measure
Measure =
CALCULATE (
COUNT ( 'Table'[ Code ] ),
FILTER (
ALL ( 'Table' ),
'Table'[Employee ] = MAX ( 'Table'[Employee ] )
&& 'Table'[ Code ] = MAX ( 'Table'[ Code ] )
)
)
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Compacted Assuming you put Employee and Code into a table visual you could use this measure:
Measure =
VAR __Employee = MAX('Table'[Employee])
VAR __Code = MAX('Table'[Code])
VAR __LastDate = MAX('Table'[Date])
VAR __MinDate = __LastDate - 50
RETURN
COUNTROWS(FILTER('Table',[Date]>=__LastDate))
Hey thanks for the help, i've tried using the solution above but it keeps returning ones in every row, and in the end the total is just the number of rows. There are 10 cases that are less than 50 days in the dataset that i am using so i was expecting to see something similar as the count result.
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 22 | |
| 22 | |
| 18 | |
| 17 | |
| 13 |
| User | Count |
|---|---|
| 61 | |
| 52 | |
| 47 | |
| 41 | |
| 38 |