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
zhivaninz
Helper I
Helper I

SUMMARIZE and measure using calculated columns returning different results for durations

The use case is processing duration for applications. Historically I've used calculated columns, but I wanted to move into 2022 and transition to using measures. However, when I tested against a test using calculated columns, I found an error I'm keen on understanding. The summarize measure was right - the calculated column, wrong. 

 

Here are my measures for the summarize:

 

 

M100 Intermediate Calendar Days Measure DO NOT USE RAW = 

var tendereddate
= MAX ( PROCESSING[Tendered_date] )

var decideddate
= MAX (PROCESSING[decision_date] )

return
DATEDIFF(
    tendereddate,
    decideddate,
    DAY
)

M101 Average calendar days using SUMMARIZE = 

var virtualtable =
SUMMARIZE(
    PROCESSING,
    PROCESSING[Application_number],
    "calendarduration",
    'Measures Table'[M100 Intermediate Calendar Days Measure DO NOT USE RAW]
)

return
AVERAGEX(
    virtualtable,
    [calendarduration]
)

 

And my column and measure for the other approach:

 

Column =
Calendar Days Tendered to Decision = 
DATEDIFF(
    PROCESSING[Tendered_date],
    PROCESSING[decision_date],
    DAY
)

Measure = 
M102 Average Calendar Days CALCULATE COLUMN = 
AVERAGE(PROCESSING[Calendar Days Tendered to Decision])

 

 

The two measures returned different results. For example, the average for one week was 13.62 using SUMMARIZE, and 14.11 using the calculated column. I then extracted the data at row level (to enable testing) to Excel and did some tests.

 

Both M101 and M102 returned values for 8697 applications (COUNTA)

Both M101 and M102 returned a total sum of 118432 days elapsed (SUM)

Dividing 118432 by 8697 gives 13.62 - not 14.11

So why is M102 behaving differently? It returns the same result as M101 at a row level.

1 ACCEPTED SOLUTION
zhivaninz
Helper I
Helper I

As always, further testing solved it.

The issue was there being duplicate application numbers, with different tendered/decision dates

Filtering both approaches down to the first application meant they returned the same result.

 

I will leave the post up as others may have a similar issue

Summarize, duplicates, duration, calculated column, datediff

View solution in original post

1 REPLY 1
zhivaninz
Helper I
Helper I

As always, further testing solved it.

The issue was there being duplicate application numbers, with different tendered/decision dates

Filtering both approaches down to the first application meant they returned the same result.

 

I will leave the post up as others may have a similar issue

Summarize, duplicates, duration, calculated column, datediff

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.