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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
nmckeown1
Helper II
Helper II

Average of DateDIFF in Power BI

I'm trying to calculate an average measure for the datediff column 'Engagement Time in the service (in days)'

The calculated table is:

 

Total Days in service =
SUMMARIZECOLUMNS(
'Aggregated Daily'[client_key],
"Session Start Date", MIN('Aggregated Daily'[start_date]),
"Discharge Date", MAX('Aggregated Daily'[discharge_date]),
"Engagement Days",DATEDIFF(MIN('Aggregated Daily'[start_date]),MAX('Aggregated Daily'[discharge_date]),DAY))
 
The column for engagement days is calulating the datediff correctly.
I then tried to create an average of engagement days per client:
Average engagement time =
AVERAGE('Engagement Date'[Engagement Time in sessions])
 
This gives incorrect average when compared to exporting the data into excel. Average is 23.36 in PB and 45.87 in excel (which I checked manually and is correct average). The column contains all whole numbers and the format is all dates and whole numbers.
 
nmckeown1_0-1724760310795.png

 

 
 
1 ACCEPTED SOLUTION


divide( 
SUM('table'[Engagement Time in sessions]), 
countrows(VALUES('Engagement Date'[client_key])
)

Since averagex ignore the blank values, can you try this.

View solution in original post

5 REPLIES 5
nmckeown1
Helper II
Helper II

Update:

 

I created a measure for total engagement days, instead of using the column for this. Calculates the same values.

Engaged =
CALCULATE(SUM('table'[Engagement Time in sessions]))
nmckeown1_0-1724762733610.png

 

I then used the dax measure to calculate an average:

average days engaged =
AVERAGEX(
    VALUES('Engagement Date'[client_key]),
    [Engaged]
)
 
This poplulated an average of '47.45' days, which brings me closer to the excel average (45.87) - but still not matching exactly?


divide( 
SUM('table'[Engagement Time in sessions]), 
countrows(VALUES('Engagement Date'[client_key])
)

Since averagex ignore the blank values, can you try this.

because I will have to write some dax code and check where the difference is coming.

can you share the pbix.
I have to look.

Anonymous
Not applicable

Why do need the file?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.