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
Anonymous
Not applicable

Calculate date difference from two different tables and exclude the weekends

Hello all!  I'm still learning how to use Power BI, Currently im stuck in this problem.

I need to get the difference between two dates from 2 different tables and i need to exclude the weekends.

I used datediff but ofcourse i need to filter out the weekends.  I tried several solutions i found here in the community but still doesnt solve my problem. 😞

 

 

Daet.PNG

3 REPLIES 3
Anonymous
Not applicable

dear my friend use this formula 

date diffrence  = DATEDIFF(Review[Review date ].[Date],RELATED(Response[Response date]),DAY)

There are many ways to solve this. One way I like is to add a column in a calendar table that indicates week days vs weekends. You could put 1 for a week day and 0 for a weekend. 

 

Read about calendar tables here https://exceleratorbi.com.au/power-pivot-calendar-tables/

 

in this case the calendar table would not be joined to your data table. Read about that here https://powerpivotpro.com/2016/12/how-many-working-days-has-an-employee-been-off-work/

 

you can then write a measure that filters your calendar table and adds up the weekday column. 

 

Working days = 

var start = table[startdate]

var end = table[enddate]

 

Return calculate(sum(calendar[working days]),(filter(calendar, calendar[date] >= start && calendar[date]<=end))



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
Anonymous
Not applicable

Hi i actually created a column which determines if that day is a weekday or weekend. 

 

WorkingDays.PNG

 

And then i created a column that relates to other table.

 

Related.PNG

 

Here is the calculated column i created:

 

DateDifference.PNG

And here is the result: Im not getting the correct answer.  😞

 

Table.PNG

 

i tried the solution below but i cant declare the other table 

Measure.PNG

 

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.