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!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Hi,
I'm using DirectQuery and i want to calculate the start date - end date without the weekend (Friday and Saturday) through a custom column. Can you help me?
Solved! Go to Solution.
Hi @Banan
When you use the calendar() funciton, then first date you need to input the start date, then second date you need to input the end date, the end date need to be greater than the start date, for the error message you offered , you didn't put the start date in the first date. You can refer to the following link.
CALENDAR function (DAX) - DAX | Microsoft Learn
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Banan
If you want to add the custom column in power query in direct query mode, the custom column cannot be applied, becuse in direct mode, the steps in power query have limitations,you can refer to the following link.
The direct mode have limitations in transform data and data modeling, you can refer to the following link.
The best way is to change the direct mode to import mode, then you can use the custom column, you can refer to the following sample.(the connect mode is import)
Sample data
Add a custom column
List.Sum(List.Transform(List.Dates([dt1],Duration.Days([dt2]-[dt1])+1,#duration(1,0,0,0)),each if Date.DayOfWeek(_,Day.Sunday)<5 then 1 else 0))
Output
If you cannot change the mode to import mode, please consider to create a measure, you can refer to the following measure.
Measure =
VAR a =
ADDCOLUMNS (
CALENDAR ( MIN ( SQLTest[dt1] ), MAX ( SQLTest[dt2] ) ),
"Weekday", WEEKDAY ( [Date], 2)
)
RETURN
COUNTROWS ( FILTER ( a, [Weekday] <> 5 && [Weekday] <> 6 ) )
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
There is no error in the code, but when I create a chart and use the new measure, this message appears " MdxScript(Model) (8,8) calculation error in measure "table name[Measure]: the start date in calender function can not be later than end date".
Note: The weekend in our country is Friday and Saturday
There is no error in the code, but when I create a chart and use the new measure, this message appears " MdxScript(Model) (8,8) calculation error in measure "table name[Measure]: the start date in calender function can not be later than end date".
Note: The weekend in our country is Friday and Saturday
Hi @Banan
When you use the calendar() funciton, then first date you need to input the start date, then second date you need to input the end date, the end date need to be greater than the start date, for the error message you offered , you didn't put the start date in the first date. You can refer to the following link.
CALENDAR function (DAX) - DAX | Microsoft Learn
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.