cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
zhivaninz
Frequent Visitor

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
Frequent Visitor

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
Frequent Visitor

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors