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
mscabrera
Helper I
Helper I

Compliance based in logged or not logged hours

Hi everyone

I've been having troubles trying to solve the following issue

I need to calculate and present the compliance % based on if the user logged hours in a week (but should work for any period of time, months, quarter, year) 

SAMPLE DATASET:
https://we.tl/t-eNKUcWl8W0

the expected outcome is something like this for the Name2 from the sample dataset

WeekLoggedPending
1/1/2024 - 1/7/2024 1
1/8/2024 - 1/14/2024 1
1/15/2024 - 1/21/2024 1
1/22/2024 - 1/28/2024 1
1/29/2024 - 2/4/2024 1
2/5/2024 - 2/11/2024 1
2/12/2024 - 2/18/2024 1
2/19/2024 - 2/25/20241 
2/26/2024 - 3/3/20241 
3/4/2024 - 3/10/20241 
3/11/2024 - 3/17/20241 
3/18/2024 - 3/24/20241 
3/25/2024 - 3/31/2024 1

If the user log at least one hour in the selected period, it should count as 100% in the prior example for the Name2, the compliance is 38,46%, because the user logged at least one hour in 5 weeks of the 13 weeks of current year (I have a column that just filter the data until current day/week) . 5/13 = 38,46%.

This needs to be scalable and presented in a stacked column chart with a legend that shows the logged and the pending hours.

Hope someone can help me with this.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @mscabrera ,

 

Please try code as below to create measures.

Compliance % = 
VAR _CountLogged = COUNTX(SUMMARIZE(LoggedHours,dimDate[CustomWeek],dimEmployees[Name]),[Logged])
VAR _CountWeek = COUNTAX(VALUES(dimDate[CustomWeek]),[CustomWeek]) * DISTINCTCOUNT(dimEmployees[Name])
RETURN
DIVIDE(_CountLogged,_CountWeek)
Pending = 
 IF(
    [Logged] = 0,
    1, 0
 )

Result is as below.

vrzhoumsft_0-1711612624853.png

 

Best Regards,
Rico Zhou

 

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

 

View solution in original post

3 REPLIES 3
mscabrera
Helper I
Helper I

@Anonymous  I just found that for the compliance% the measure is not taking into account the date the person started (dimEmployees[Start Date]) the denominator of compiance% should count the weeks from when the employee started, and ignore the previous ones. Is there a way to incoporate something like this in the formula:

FILTER(
        dimDate,
        dimDate[Date] <= MAX(dimDate[End Date2]) && dimDate[Date] >= MIN(dimDate[Start Date])
    ),
Anonymous
Not applicable

Hi @mscabrera ,

 

Please try code as below to create measures.

Compliance % = 
VAR _CountLogged = COUNTX(SUMMARIZE(LoggedHours,dimDate[CustomWeek],dimEmployees[Name]),[Logged])
VAR _CountWeek = COUNTAX(VALUES(dimDate[CustomWeek]),[CustomWeek]) * DISTINCTCOUNT(dimEmployees[Name])
RETURN
DIVIDE(_CountLogged,_CountWeek)
Pending = 
 IF(
    [Logged] = 0,
    1, 0
 )

Result is as below.

vrzhoumsft_0-1711612624853.png

 

Best Regards,
Rico Zhou

 

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

 

Hi @Anonymous 

Thank you so much for your response, it works perfect!! although I have to mention that the only downside is the visualization in the bar chart doesn't reflect  numbers of the compliance % when seeing it for all names, fo a specific user (name2) it shows the weeks when the user logged hours and when he didn't, but when clearing the filter it shows everything as logged except the week when no one logged hours

mscabrera_2-1711985582616.png

It should show me that for the first 7 weeks of the year, 2 users (name1 & name2) didn't logged hours out of the 8 users, but I guess this has something to do with the way the measure is set, in order to have it the way I wanted, the Logged and Pending status would need to be in the table and added to the bar chart as a legend, right?

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