Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi guys,
I had a different post in which I asked help with my formule for the days between two dates using four different dates. That is fixed... well not completely..
The formula below does indeed work correct. However, I only want the working days. Can someone explaine how to fix this?
min date = MIN('date'[Date])
max date = MAX('date'[Date])
range =
VAR s =
MAX ( 'Table'[start date] )
VAR e =
MAX ( 'Table'[end date] )
RETURN
IF([max date]>=s&&[max date]<=e,IF([min date]>=s,"midlle","left"),IF([max date]>e,IF([min date]<=e,"right","na"))
whole days =
SWITCH (
[range],
"midlle", DATEDIFF ( [min date], [max date], DAY ) + 1,
"left", DATEDIFF ( MAX ( 'Table'[start date] ), [max date], DAY ) + 1,
"right", DATEDIFF ( [min date], MAX ( 'Table'[end date] ), DAY ) + 1,
0
)Thanks!
Solved! Go to Solution.
Hi @Anonymous
Based on the formula above, i work out the days of weekend in these periods.
weekend =
VAR right_weekend =
CALCULATE (
COUNT ( 'date'[Date] ),
FILTER (
'date',
[Date] >= [min date]
&& [Date] <= MAX ( 'Table'[end date] )
&& WEEKDAY ( [Date], 2 ) >= 6
)
)
VAR left_weekend =
CALCULATE (
COUNT ( 'date'[Date] ),
FILTER (
'date',
[Date] >= MAX ( 'Table'[start date] )
&& [Date] <= [max date]
&& WEEKDAY ( [Date], 2 ) >= 6
)
)
VAR midlle_weekend =
CALCULATE (
COUNT ( 'date'[Date] ),
FILTER (
'date',
[Date] >= [min date]
&& [Date] <= [max date]
&& WEEKDAY ( [Date], 2 ) >= 6
)
)
RETURN
SWITCH (
[range],
"right", right_weekend,
"left", left_weekend,
"midlle", midlle_weekend,
0
)
final days = [whole days]-[weekend]
Hi @Anonymous
Based on the formula above, i work out the days of weekend in these periods.
weekend =
VAR right_weekend =
CALCULATE (
COUNT ( 'date'[Date] ),
FILTER (
'date',
[Date] >= [min date]
&& [Date] <= MAX ( 'Table'[end date] )
&& WEEKDAY ( [Date], 2 ) >= 6
)
)
VAR left_weekend =
CALCULATE (
COUNT ( 'date'[Date] ),
FILTER (
'date',
[Date] >= MAX ( 'Table'[start date] )
&& [Date] <= [max date]
&& WEEKDAY ( [Date], 2 ) >= 6
)
)
VAR midlle_weekend =
CALCULATE (
COUNT ( 'date'[Date] ),
FILTER (
'date',
[Date] >= [min date]
&& [Date] <= [max date]
&& WEEKDAY ( [Date], 2 ) >= 6
)
)
RETURN
SWITCH (
[range],
"right", right_weekend,
"left", left_weekend,
"midlle", midlle_weekend,
0
)
final days = [whole days]-[weekend]
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 35 | |
| 34 | |
| 31 | |
| 27 |
| User | Count |
|---|---|
| 135 | |
| 102 | |
| 67 | |
| 65 | |
| 56 |