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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Joao_C_Faria
Helper I
Helper I

Datediff with filter

Good morning,

I have a table with a calendar, a column with the dates and a column with the number 1 for the days the company is open and 0 for the days the company is closed.

I have another table with a column with the start of production date and another with the end.

I need to datediff, filtering only the days the company is open, =1.

I can't understand how this dont work: 

Time Spent = CALCULATETABLE(datediff('Production'[Startdate],'Production'[Date Time],HOUR),FILTER(DateCalendar,DateCalendar[Workday]=1))

 

1 ACCEPTED SOLUTION

@Joao_C_Faria , id start date and end date are column in same table :Production, you can create a column in Production

 

new column = countx(filter(DateCalendar, DateCalendar[Date] >= Production[Start Date] && DateCalendar[Date] <= Production[End Date] && DateCalendar[Workday]=1),DateCalendar[Date])

 

 

else you have to take a measure approch

 

How to calculate Business Days/ Workdays, with or without date table: https://youtu.be/Qv4wT8_P-AA

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Joao_C_Faria
Helper I
Helper I

The number 1 in the calendar table represents the company being open, and it's in text format, I tried to do "1", but it didn't work either.

Joao_C_Faria
Helper I
Helper I

First of all, thank you for availability.

Says the expression references multiple columns. It is not possible to transform several columns into a scalar value.

I send the images as an attachment to make it easier, I changed the name of the columns that were in Portuguese to make it more readable.

Compliments
I need to know the number of business days between startdate and enddate.

Thank you very much.


2.png3.png

@Joao_C_Faria , id start date and end date are column in same table :Production, you can create a column in Production

 

new column = countx(filter(DateCalendar, DateCalendar[Date] >= Production[Start Date] && DateCalendar[Date] <= Production[End Date] && DateCalendar[Workday]=1),DateCalendar[Date])

 

 

else you have to take a measure approch

 

How to calculate Business Days/ Workdays, with or without date table: https://youtu.be/Qv4wT8_P-AA

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
amitchandak
Super User
Super User

@Joao_C_Faria , create a new column in production

new column = countx(filter(DateCalendar, DateCalendar[Date] >= Production[Start Date] && DateCalendar[Date] <= Production[End Date] && DateCalendar[Workday]=1),DateCalendar[Date])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors