Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Duartegarcia
New Member

measure - Count nº of week days between two dates using direct query mode

Hi all,

 

I am trying to create a measure in Power Bi, but I am having difficulties to get the result I want.

 

I want to count the nº of weekdays between two dates in the same table using direct query mode.

 

The measure I wanted to create is something like this 

Measure = CALCULATE([Week Days]);DATEDIFF(MIN('Table1'[PeriodBegin]);MAX('Table1'[PeriodEnd]);DAY))

 

The measure 'Week Days' counts the number of days in a column(WeekDay) within Date table that is "1" in a weekend day and "0" in a week day. So measure 'Week Days' counts all the "0"s

I want to get the nº of week days within this analysis between the oldest date (Min Period Begin) and the newest date (Max Period End)

 

An issue I found using Direct Query Mode is that is not possible to use the "DatesBetween" and "FirstDate" functions.

 

Please help 😉

 

Thanks

 

2 REPLIES 2
Duartegarcia
New Member

Hi all,

 

I am trying to create a measure in Power Bi, but I am having difficulties to get the result I want.

 

I want to count the nº of weekdays between two dates in the same table using direct query mode.

 

The measure I wanted to create is something like this 

Measure = CALCULATE([Week Days]);DATEDIFF(MIN('Table1'[PeriodBegin]);MAX('Table1'[PeriodEnd]);DAY))

 

The measure 'Week Days' counts the number of days in a column(WeekDay) within Date table that is "1" in a weekend day and "0" in a week day. So measure 'Week Days' counts all the "0"s

I want to get the nº of week days within this analysis between the oldest date (Min Period Begin) and the newest date (Max Period End)

 

An issue I found using Direct Query Mode is that is not possible to use the "DatesBetween" and "FirstDate" functions.

 

Please help 😉

 

Thanks

 

AkhilAshok
Solution Sage
Solution Sage

Have you tried enabling this options: Options & Settings -> Options -> DirectQuery -> Allow Unrestricted Measures in DirectQuery mode

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.