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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I need to calculate the number of weeks between the two date rows based on the category start date and finish date as shown below
Solved! Go to Solution.
Hi @Anonymous
Try to use datediff function in your code.
Weekdiff =
VAR _T =
SUMMARIZE (
'Table',
'Table'[SDCCode],
"Weekdiff",
VAR _LoadStartDate =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Category] = "03.WO Load Start Date" )
)
VAR _LoadFinishDate =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Category] = "04.WO Load Finish Date" )
)
RETURN
DATEDIFF ( _LoadStartDate, _LoadFinishDate, WEEK )
)
RETURN
SUMX ( _T, [Weekdiff] )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Try to use datediff function in your code.
Weekdiff =
VAR _T =
SUMMARIZE (
'Table',
'Table'[SDCCode],
"Weekdiff",
VAR _LoadStartDate =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Category] = "03.WO Load Start Date" )
)
VAR _LoadFinishDate =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Category] = "04.WO Load Finish Date" )
)
RETURN
DATEDIFF ( _LoadStartDate, _LoadFinishDate, WEEK )
)
RETURN
SUMX ( _T, [Weekdiff] )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 10 | |
| 10 | |
| 4 | |
| 3 | |
| 3 |