Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi All - i need DAX Measure which can add up total number of Working Days when date range is selected in a slicer in PowerBi?
It has to be a measure !! Suppose date range selected is 10-Jan-2019 till 30-May-19, i want to know sum of working days between these two dates.
Any help would be helpful. Anyone please?
Solved! Go to Solution.
Hey @navedkhan
I guess this will do the trick:
Number of WorkDays = var weekdays = {1, 2, 3, 4, 5} return SUMX( VALUES('Table1'[Date]) , var isWeekDay = IF(WEEKDAY([Date],2) IN weekdays, 1, BLANK()) return isWeekDay )
From a personal point of view, I would not create a calculated column as there are repeated dates because your table is not a dedictated Calendar table, but this is just my personal thinking. And even a dedicated Calendar table would be of no help, as your requirement is to calculate the workingdays in your "fact" table.
Hopefully this is what you are looking for.
Regards,
Tom
You can achieve this create a calculated column first. Below is the DAX.
Hope this helps !!
Please mark the solution as accepted if it was appropriate.
Thanks
thanks for your guidance. i applied the steps as mentioned but am not getting exactly what you showed or i wanted;
after creating the measure am getting wierd totals between 30-Nov-18 till 31-May-19 am getting No. of Working Days=5609234 days which is incorrect.
Please note that i've only one Date column and those dates are repeated in various rows as it captures per entry of employees who have entered a premise. so i guess that's why its adding up and inflating actual no. of working days.
pls can you help resolve this further? and what to do to ignore Public Holidays?
Hi @navedkhan
Can you try using DISTINCTCOUNT in your measure after creating the calculated column IsWeekDay as mentioned in the previous replies?
For example: CALCULATE(DISTINCTCOUNT(Table[IsWeekDay]))
Hope this helps!
Regards,
Suguna.
No DISTINCTCOUNT doesn't work at all....
1) one column for Dates
2) when slicer is moved to and fro
i need to calculate total no. of working days between to and fro slicer selection.
Pls suggest simple MEASURE!!
Hey @navedkhan
I guess this will do the trick:
Number of WorkDays = var weekdays = {1, 2, 3, 4, 5} return SUMX( VALUES('Table1'[Date]) , var isWeekDay = IF(WEEKDAY([Date],2) IN weekdays, 1, BLANK()) return isWeekDay )
From a personal point of view, I would not create a calculated column as there are repeated dates because your table is not a dedictated Calendar table, but this is just my personal thinking. And even a dedicated Calendar table would be of no help, as your requirement is to calculate the workingdays in your "fact" table.
Hopefully this is what you are looking for.
Regards,
Tom
Hi,
Please try this:
https://community.powerbi.com/t5/Desktop/equivalent-function-of-Networkdays-in-DAX/td-p/245103
Thanks,
Vivek
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Make some sort of column in your date table that highlights if a date is a Saturday/Sunday, and count the number of rows that aren't flagged. Can do similar with public holidays by making a list of when they are and joining it to your calendar table
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |