Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.