Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I have a problem with this metric. I need to count the working days between the two dates. In some moments, the metric works perfectly, but in other situations, it does not work like in the example.
Anybody know why?
Thank you for your comments.
Solved! Go to Solution.
Hi @MTrullàs
It is difficult to verify how columns are evaluated within the filter context without having the data in front of your eyes. However, I would follow a totally different approach. I would create my own calendar table. The only thing is that I don't know what are you expecting to see if either of the start/end dates is blank? I just return zero.
Transporte Campa =
VAR StartDay =
MAX ( HIFA[Ch35 (WERK-AUS) Ist] )
VAR EndDay =
MAX ( HIFA[Ch38 (DEP-EIN) Ist] )
RETURN
IF (
ISBLANK ( StartDay ) || ISBLANK ( EndDay ),
0,
VAR DatesTable =
CALENDAR ( StartDay, EndDay - 1 )
VAR DatesAndWeekDays =
ADDCOLUMNS ( DatesTable, "@WeekDay", WEEKDAY ( [Date], 2 ) )
VAR WorkDaysTable =
FILTER ( DatesAndWeekDays, NOT ( [@WeekDay] IN { 6, 7 } ) )
RETURN
COUNTROWS ( WorkDaysTable )
)
Thank you very much for the answer!
Hi @MTrullàs
It is difficult to verify how columns are evaluated within the filter context without having the data in front of your eyes. However, I would follow a totally different approach. I would create my own calendar table. The only thing is that I don't know what are you expecting to see if either of the start/end dates is blank? I just return zero.
Transporte Campa =
VAR StartDay =
MAX ( HIFA[Ch35 (WERK-AUS) Ist] )
VAR EndDay =
MAX ( HIFA[Ch38 (DEP-EIN) Ist] )
RETURN
IF (
ISBLANK ( StartDay ) || ISBLANK ( EndDay ),
0,
VAR DatesTable =
CALENDAR ( StartDay, EndDay - 1 )
VAR DatesAndWeekDays =
ADDCOLUMNS ( DatesTable, "@WeekDay", WEEKDAY ( [Date], 2 ) )
VAR WorkDaysTable =
FILTER ( DatesAndWeekDays, NOT ( [@WeekDay] IN { 6, 7 } ) )
RETURN
COUNTROWS ( WorkDaysTable )
)
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
9 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
11 | |
11 | |
10 | |
6 |