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

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.