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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ajitsahoo8338
Helper III
Helper III

How to calculate the weekdays of each employee?

Employee NameDate
Adam 08/21/2024
Adam 08/22/2024
Adam 08/23/2024
Adam 08/24/2024
Adam 08/26/2024
Adam 08/27/2024
Mike08/21/2024
Mike08/22/2024
Mike08/23/2024
Mike08/26/2024
Mike08/27/2024

 

My requirement is to calculate weekday of each employee. I am using this below code to calculate weekdays

 

 

 

Count of Weekdays = var weekdays = {1, 2, 3, 4, 5}
return
SUMX(
    VALUES(Employee_Hrs_Dataset_TBL[Date])
    , var isWeekDay = IF(WEEKDAY([Date],2) IN weekdays, 1, BLANK())
    return
    isWeekDay
)

 

 

 

 but the sum of this calculation is showng 6  weekdays  but total should show 11 . 6 for Adam and 5 for Mike. How can I acheive this?

 

Thank You,

Ajit

5 REPLIES 5
rajendraongole1
Super User
Super User

Hi @ajitsahoo8338 - as per given sample data, there is saturday it is getting ignored as we need to find only weekdays.

 

please find the below measure:

 

Count of Weekdays =
VAR weekdays = {1, 2, 3, 4, 5}
RETURN
SUMX(
    FILTER(
        empl,
        WEEKDAY(empl[Date], 2) IN weekdays
    ),
    1
)

rajendraongole1_0-1724840440338.png

 

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hello @rajendraongole1 Thank you for your response. I have used your code. But after using it my data look like this. Here I have used a visual level Date filter to show data from  20th august 2024 to 27th august 2024 and employee filter to show adam and aiden. Any idea why weekdays is showing wrong?

Employee NameYearMonthDayWEEKdAYS
Adam Fergen2024August2010
Adam Joslin2024August205
Adam Fergen2024August216
Adam Joslin2024August214
Adam Fergen2024August227
Adam Joslin2024August224
Adam Fergen2024August235
Adam Joslin2024August233
Adam Fergen2024August268
Adam Joslin2024August261
Adam Fergen2024August276
Adam Joslin2024August271

Hey @ajitsahoo8338 - Can you please check the first question with expectations what is the ask there?

 

"sum of this calculation is showng 6  weekdays  but total should show 11 . 6 for Adam and 5 for Mike."--> due to one of the date is falling in saturday we are getting the adam 5 and mike 5

rajendraongole1_0-1724842028466.png

Above is expected output achieved.

 

Now, be clear can you please share sample data as input with expectations as checked in above information there is no name called  "aiden"

 

Hope it helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Sorry My mistake output should be 10.

Hi @ajitsahoo8338 Thanks for the confirmation, if your query resolved. please mark this as a solution 

 

Thank you





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.