Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
In this dataset, I have rows of data that share the same 'PhaseID'. I want to calculate the differance (in days) between the first 'ScheduledStartDate' and the last 'ScheduledCompleteDate' for each row that shares the same 'PhaseID'.
For Example, for PhaseID 89578 the first ScheduledStartDate = 10/22/21 and the last ScheduledCompleteDate = 11/8/2021 so the differance would be 18 days. I also want to exclude weekends in the calculation.
Help is appreciated!
Solved! Go to Solution.
Hi @vincenardo
You can try this measure to get diff between ScheduledStartDate & ScheduledCompleteDate.
diff =
var _min=CALCULATE(MIN('Table'[ScheduledStartDate]),ALLEXCEPT('Table','Table'[PhaseID]))
var _max=CALCULATE(MAX('Table'[ScheduledCompleteDate]),ALLEXCEPT('Table','Table'[PhaseID]))
return
DATEDIFF(_min,_max,DAY)+1
and if you want to exclude weekends in the calculation, then add a calendar table, and use the measure bellow
diff =
var _min=CALCULATE(MIN('Table'[ScheduledStartDate]),ALLEXCEPT('Table','Table'[PhaseID]))
var _max=CALCULATE(MAX('Table'[ScheduledCompleteDate]),ALLEXCEPT('Table','Table'[PhaseID]))
return
CALCULATE(COUNTROWS('Calendar'),DATESBETWEEN('Calendar'[Date],_min,_max),'Calendar'[Isweekday]<>7&&'Calendar'[Isweekday]<>1)
result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hi @vincenardo
You can try this measure to get diff between ScheduledStartDate & ScheduledCompleteDate.
diff =
var _min=CALCULATE(MIN('Table'[ScheduledStartDate]),ALLEXCEPT('Table','Table'[PhaseID]))
var _max=CALCULATE(MAX('Table'[ScheduledCompleteDate]),ALLEXCEPT('Table','Table'[PhaseID]))
return
DATEDIFF(_min,_max,DAY)+1
and if you want to exclude weekends in the calculation, then add a calendar table, and use the measure bellow
diff =
var _min=CALCULATE(MIN('Table'[ScheduledStartDate]),ALLEXCEPT('Table','Table'[PhaseID]))
var _max=CALCULATE(MAX('Table'[ScheduledCompleteDate]),ALLEXCEPT('Table','Table'[PhaseID]))
return
CALCULATE(COUNTROWS('Calendar'),DATESBETWEEN('Calendar'[Date],_min,_max),'Calendar'[Isweekday]<>7&&'Calendar'[Isweekday]<>1)
result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
@vincenardo , You can create a new column like
Work Day = COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR(Table[ShceduleStartDate],Table[ShceduleCompleted Date]),"WorkDay", if(WEEKDAY([Date],2) <6,1,0)),[WorkDay] =1))
Business Days/ Workdays, with or without date table: https://youtu.be/Qv4wT8_P-AA
Thanks. I have an error becuase I also have records with blank dates in the date fields. What conditional statement could I add?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
71 | |
56 | |
39 | |
35 |
User | Count |
---|---|
66 | |
66 | |
59 | |
53 | |
45 |