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.
Hello Everyone.
My intent is to calculate the number of working days for each month and display the number for the current month to get an average, For Example.
I created a report that tracks the number of lines processed, I would like to automatically devide the number of lines processed with the number of working days for the current month . I can do this manually = Countoflines / 22 but I would have to change the number of working days each month. Will it be possible to have this automated so that when we switch to the next month it changes automatically?
Solved! Go to Solution.
Hi @carlosagarcia,
Here is a calculated column expression that can be used to calculate the current month workdays(except weekend) based on date value, you can try it if helps:
CMonthWorkDay=
VAR currDate ='Date'[Date]
RETURN
COUNTROWS (
FILTER (
GENERATESERIES (
DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 ),
DATE ( YEAR ( currDate ), MONTH ( currDate ) + 1, 1 ) - 1
),
WEEKDAY ( [Date], 2 ) <= 5
)
)
Regards,
Xiaoxin Sheng
Hi @carlosagarcia,
if you can please share some dummy data that keep the raw data structure and expected results. It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
Hello @v-shex-msft What I want to do it is to count the working days for the current month.
For example in this case July 2021 has 22 working days, I want to be able to see the working days displated on a card or a table so I can use it to get an average of lines processed.
This seems to be a good method but I am unable to recreate the MonthYear table.
Hi @carlosagarcia,
Here is a calculated column expression that can be used to calculate the current month workdays(except weekend) based on date value, you can try it if helps:
CMonthWorkDay=
VAR currDate ='Date'[Date]
RETURN
COUNTROWS (
FILTER (
GENERATESERIES (
DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 ),
DATE ( YEAR ( currDate ), MONTH ( currDate ) + 1, 1 ) - 1
),
WEEKDAY ( [Date], 2 ) <= 5
)
)
Regards,
Xiaoxin Sheng
Do you have a Date table with a column to indicate working days? If so, you can use an expression like this
Count per WD =
VAR countoflines = [Your Count Measure]
VAR WD =
CALCULATE ( COUNTROWS ( 'Date' ), 'Date'[IsWorkingDay] = "Y" )
RETURN
DIVIDE ( countoflines, WD )
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hello Ma,
I do not have a date table, I treid different methods over the weekend with various posts and I could not find one that will give the total amount of days, it was always decending one by one.
This is as far as I got.
WorkingDaysCurrentMonth =
VAR __Calendar =
ADDCOLUMNS(
CALENDAR(DATE(2021,1,1),DATE(2021,12,31))
"IsWorkDay", IF(WEEKDAY([Date],2),1,0)
)
VAR __Today = TODAY()
VAR __Start = DATE(YEAR(__Today),MONTH(__Today),1)
VAR __End = EOMONTH(__Today,0)
RETURN
COUNTROWS(FILTER(__Calendar,[IsWorkDay]=1 && [Date] >=__Start && [Date]<=__End))
@carlosagarcia Sorry, syntax error, should be:
"IsWorkDay", IF(WEEKDAY([Date],2)<6,1,0)
@Greg_Deckler when you reffer to IsWorkDay what are you refering too?
The Dax query still does not recognize that name. I really apreciate the help.
@carlosagarcia So, generally, you can create a "IsWorkingDay" column in your calendar table using something like:
IsWorkingDay = IF(WEEKDAY([Date],2)<6,1,0)
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 |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |