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

Duration Displayed on Card

Hello,

 

I am working with Google Analytics data and attempting to display a card with the Average Session Duration. I have created a custom column to display this data on my table in Power Query with the following formula:

 

= Table.AddColumn(#"Changed Type", "Average Session Duration", each [Session Duration] / [Sessions])

 

 I know from viewing GA that the outcome I'm looking for is 0:01:17. From working with the data in Excel, I know that I can get the right answer with the following equation: Sum(Session Duration) / Sum(Sessions).

Excel Extract.PNG

When I go to display this value on a card, it shows as a decimal.

As time. Only Summarization options are "Don't Summarize" and "Count"As time. Only Summarization options are "Don't Summarize" and "Count"

I changed the Data Type to "Time" to get to the format but I can only Summarize the data with "Count" or "Don't Summarize", neither of which give me the average that I'm looking for.

As a decimal numberAs a decimal number

 My calculation may be wrong but I can't tell based on the output that I'm getting. Any thoughts on how to get to the right number and display?

1 ACCEPTED SOLUTION

What you could do is create a calculated column:

 

averagepersessioncol = 'Table'[Total Session Duration]/'Table'[Sessions]

 

And a measure:

 

durationpersession = Format(AVERAGE('Table'[averagepersessioncol]); "HH:MM:SS")

 

For the 3rd and 4rth row this yields:

time.png

Which is the average of averages.. like here in excel:

time2.png

 

Link to Power BI file here

 

please mark as solution if this works for you.

 

Kind regards, Steve. 

View solution in original post

9 REPLIES 9
harshnathani
Community Champion
Community Champion

Hi @wcameron14 ,

 

 

You can try the following measure

 

Display =

var TSD = CALCULATE(Sum('Table'[Total Session Duration]),ALLSELECTED('Table'[Date]))
Var Sess = CALCULATE(Sum('Table'[Total Session]),ALLSELECTED('Table'[Date]))

RETURN
DIVIDE (TSD,Sess)
 
Regards,
Harsh Nathani

This still displays a decimal on the card. Maybe there's something I'm doing wrong with the formatting of my visual?

What you could do is create a calculated column:

 

averagepersessioncol = 'Table'[Total Session Duration]/'Table'[Sessions]

 

And a measure:

 

durationpersession = Format(AVERAGE('Table'[averagepersessioncol]); "HH:MM:SS")

 

For the 3rd and 4rth row this yields:

time.png

Which is the average of averages.. like here in excel:

time2.png

 

Link to Power BI file here

 

please mark as solution if this works for you.

 

Kind regards, Steve. 

This helped with the formatting. My formula isn't quite right but I think I can figure it out from there. Thanks for the help!

@stevedep I went back and added pictures to the post to make it a little easier to understand. 

Thanks, that's helpful. How is the session duration stored in your dataset? Is it a duration in seconds or minutes (sum of)?

It is stored as a duration in the dataset. D.hh:mm:ss.0 (See below).

duration data.PNG

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.