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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
MEHUL123
Frequent Visitor

DAX for percentage attendance in powerbi

Hi,

 

I have 2 tables,

1) Datetable (having date, months, years)

2) Employee roll wise and date wise attendance

 

I want to display %Attendance of each employee in output

i.e.  --  ideal work days (day count in excluding sunday on any specific month or combination of multiple months) vs actual worked days of any employee for that specific period

Let Say,

EMP_IDTOTAL work days of specific monthsActual Worked Days of employee on those months%Attendance
123262077%
345262181%
567262596%
7892627104%
TOTAL2623.2589%

 

However when i select multiple months (let say selection of Jan25 and Feb25 in filter), than i want sum of 2 month's work days,

means [26 work days (jan25)  + 24 work days (feb25)] = 50 work days total...

 

pls guide, thanks in advance.

 

1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

Hi @MEHUL123 ,
To calculate % Attendance in Power BI based on your two tables — a DateTable and an AttendanceTable (employee attendance records), you’ll need to approach this by comparing the number of ideal working days (excluding Sundays) from the date table against the actual worked days from the attendance records.

 

The key is to make sure both tables are linked via date, and that your DAX logic adjusts dynamically when multiple months are selected. You can then use DAX measures to calculate total workdays, actual attendance, and finally the percentage. This approach will respect any filters (like month slicers) and provide correct calculations even when multiple months are selected.

 

Step 1: Measure for Total Working Days (excluding Sundays)

TotalWorkingDays =
CALCULATE(
    COUNTROWS(DateTable),
    DateTable[DayName] <> "Sunday"
)

 

Step 2: Measure for Actual Worked Days (per employee)

ActualWorkedDays =
CALCULATE(
    COUNTROWS(AttendanceTable),
    AttendanceTable[Status] = "Present"  -- or whatever status indicates attendance
)

 

Step 3: Measure for % Attendance

% Attendance =
DIVIDE([ActualWorkedDays], [TotalWorkingDays], 0)

Make sure your DateTable is marked as a Date table and is properly related to the AttendanceTable on the date column. This setup will give you accurate, dynamic attendance percentages across any time period you slice by — including combinations of months, quarters, or years.

 


Passionate about leveraging data analytics to drive strategic decision-making and foster business growth.

Connect with me on LinkedIn: Rohit Kumar

View solution in original post

5 REPLIES 5
v-hashadapu
Community Support
Community Support

Hi @MEHUL123 , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @MEHUL123 , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @MEHUL123 , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.

rohit1991
Super User
Super User

Hi @MEHUL123 ,
To calculate % Attendance in Power BI based on your two tables — a DateTable and an AttendanceTable (employee attendance records), you’ll need to approach this by comparing the number of ideal working days (excluding Sundays) from the date table against the actual worked days from the attendance records.

 

The key is to make sure both tables are linked via date, and that your DAX logic adjusts dynamically when multiple months are selected. You can then use DAX measures to calculate total workdays, actual attendance, and finally the percentage. This approach will respect any filters (like month slicers) and provide correct calculations even when multiple months are selected.

 

Step 1: Measure for Total Working Days (excluding Sundays)

TotalWorkingDays =
CALCULATE(
    COUNTROWS(DateTable),
    DateTable[DayName] <> "Sunday"
)

 

Step 2: Measure for Actual Worked Days (per employee)

ActualWorkedDays =
CALCULATE(
    COUNTROWS(AttendanceTable),
    AttendanceTable[Status] = "Present"  -- or whatever status indicates attendance
)

 

Step 3: Measure for % Attendance

% Attendance =
DIVIDE([ActualWorkedDays], [TotalWorkingDays], 0)

Make sure your DateTable is marked as a Date table and is properly related to the AttendanceTable on the date column. This setup will give you accurate, dynamic attendance percentages across any time period you slice by — including combinations of months, quarters, or years.

 


Passionate about leveraging data analytics to drive strategic decision-making and foster business growth.

Connect with me on LinkedIn: Rohit Kumar

AnkitKukreja
Super User
Super User

Hi! @MEHUL123 

 

I think you are looking for this, if this doesn't help please do share a sample file.
https://www.youtube.com/watch?v=k0I-khGGXE4

 

 

For Power BI trainings or support dm or reach out to me on LinkedIn.
If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.

Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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