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
MarioE
Regular Visitor

My total is not real in a datediff calculation

Hi colleagues,

I need some help from your side, please.

I'm trying to calculate the diference between the dates marked as blue. I have created a measure that returns the DIFF PRO Date - MIN Slicer, it means the diference between the min date selected in the slicer and de field production date for each item. The result is true but the Total is not right as you can see.

The measure that I've created is :

DIFF PRO Date - MIN Slicer =
VAR StartDate =  SUM(tProcessTab[FechaProduccion])
VAR EndDate =    MIN( CalendarioEjecuciones[Date])
RETURN
        DATEDIFF ( StartDate, EndDate, DAY )
 
Could you please help me to get the right total or understand this situation? 
 
Thanks in advance.

 

MarioE_0-1739790617259.png

 

1 ACCEPTED SOLUTION
girishthimmaiah
Resolver I
Resolver I

Your total is incorrect because the SUM function on your measure is summing all production dates, which skews the calculation at the total level.

Why is this occurring?
The SUM(tProcessTab[FechaProduccion]) sums all production dates and produces an unrealistic total date.
The DATEDIFF is computed on this in-correctly aggregated date.
The calculation at the row level is correct but at the Total row, it is incorrect.
How to Fix It?
Replace SUM with SUMX, which performs row by row and provides the proper total:

DAX

DIFF PRO Date - MIN Slicer =
VAR StartDate = SELECTEDVALUE(tProcessTab[FechaProduccion])
VAR EndDate = MIN(CalendarioEjecuciones[Date])
RETURN
IF(NOT ISBLANK(StartDate), DATEDIFF(StartDate, EndDate, DAY))

View solution in original post

2 REPLIES 2
girishthimmaiah
Resolver I
Resolver I

Your total is incorrect because the SUM function on your measure is summing all production dates, which skews the calculation at the total level.

Why is this occurring?
The SUM(tProcessTab[FechaProduccion]) sums all production dates and produces an unrealistic total date.
The DATEDIFF is computed on this in-correctly aggregated date.
The calculation at the row level is correct but at the Total row, it is incorrect.
How to Fix It?
Replace SUM with SUMX, which performs row by row and provides the proper total:

DAX

DIFF PRO Date - MIN Slicer =
VAR StartDate = SELECTEDVALUE(tProcessTab[FechaProduccion])
VAR EndDate = MIN(CalendarioEjecuciones[Date])
RETURN
IF(NOT ISBLANK(StartDate), DATEDIFF(StartDate, EndDate, DAY))

Thanks a lot, you have helped me a lot.

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