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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
BIBryan
New Member

Calculate Average of a Measure

I'm measuring video views on a web page. I pull a total every few days. My data table has a list of video titles, and calculates the number of new views based on the new total minus the previous total. For each row there is a "report date".

 

In Power BI, I was able to use DAX to create a measure called "Duration" that uses the DATEDIFF formula to calculate the number of days from when the video launched to the last report date.

 

Duration = (DATEDIFF(min(MasterData[Report Date]),MAX(MasterData[Report Date]),DAY))

 

I apply a filter to the table to pull out the dates when views were below a certain threshhold. Everything looks good up to this point. I get a list that diplays the title of the video in one column and the duration of each after the low-outliers are filtered out. All I want is an average of this second column. But because it is a measure, I can't figure out how to calculate it. 

 

My primary objective in all of this is to determine the most vigorous lifespan of a video once it is launched. That is, there is a period of time when the video is hot, and then it is a mere trickle the remaining time.  I want to know the average hot span for video views--that is, how many days is a video hot for on average? 

 

Thanks in advance!

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

I'm thinking create another measure with the formula:

 

AverageDuration = AVERAGE((DATEDIFF(min(MasterData[Report Date]),MAX(MasterData[Report Date]),DAY)))

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler --thank you. I've tried that. I get the error: "The AVERAGE function only accepts a column reference as an argument."

Hmmm...

I didn't try this in testing, it's late where I am but perhaps try something like a custom column with a formula of:

 

DurationColumn = CALCULATE(DATEDIFF(min(MasterData[Report Date]),MAX(MasterData[Report Date]),DAY),ALLEXCEPT(MasterData[VideoTitle]))

I am assuming that you have a column called "VideoTitle" but just replace with actual column name.

 

Now that you have it in a column, you can take the average of it. Average could be skewed I suppose depending on your data model. Man, I must be missing something, this doesn't seem like it should be this complicated. 

 

It's late here, I don't think my brain is working properly.

 

I wonder if you could alternatively try a measure like:

AVERAGEX(MasterData,DATEDIFF(min(MasterData[Report Date]),MAX(MasterData[Report Date]),DAY))

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors