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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
nmckeown1
Helper I
Helper I

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

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.