SUMX On DateDiff?

Hello,

I have a measure like this:

Days Change Previous Report =
VAR vThisCompDate =
MIN ( Backlog[End Date (Ops)] )
VAR vThisReportDate =
MIN ( Backlog[Report Date] )
VAR vPrevCompDate =
CALCULATE (
LASTNONBLANKVALUE (
Backlog[Report Date],
MIN ( Backlog[End Date (Ops)] )
),
ALLEXCEPT (
Backlog,
Backlog[Project],
Backlog[Customer],
Backlog[Job Site]
),
Backlog[Report Date] < vThisReportDate
)
VAR DaysDiff = DATEDIFF (
vPrevCompDate,
vThisCompDate,
DAY
)
RETURN
DaysDiff

However, it doesnâ€™t sum correctly the days of difference, please see below screen. Does anyone know how to fix it?

Here is the pbix file, I have created a new â€śfakeâ€ť dataset. However, it seems that the days are not added at all now.

My goal would be to see the total days of difference, which will help me to understand what was the total days difference by customer (for example).

thank you,
Marek

Pbi_dset.pbix (85.2 KB)

Hello @marek.regulski,

Thank You for posting your query onto the Forum.

Can you please upload the working of your PBIX file for the reference? So that the members of our forum can assist you in a better manner and provide you the results more efficiently.

Thanks and Warm Regards,
Harsh

1 Like

Edited- thank you.

Hello @marek.regulski,

Thank You for providing the working PBIX file.

Well I just wrote one more small formula in order to have the grand totals. Below is the formula provided for the reference -

Days Change Previous Report - Harsh =
SUMX(
SUMMARIZE(
Pbi ,
Pbi[Project No.] ,
Pbi[Job Site] ,
Pbi[Source.Name] ,
Pbi[End Date (Ops)] ) ,
[Days Change Previous Report]
)

Iâ€™m also providing a link below where one of our expert @Greg had put up a great post about â€śHow To Fix The Totalsâ€ť.

As well as also attaching the working of my PBIX file for the reference.

Hoping you find this useful and meets your requirements that youâ€™ve been looking for.

Thanks and Warm Regards,
Harsh

Pbi_dset - Harsh.pbix (85.3 KB)

1 Like

It works!

Thank you so much for such a detailed answer and further materials. This is great.

Hello @marek.regulski,

Youâ€™re Welcome.