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

Desperately need help! Avg tickets for each hour for selected days of week in a selected date range

I have been trying every possible option for days now and I am just going around in circles.  I have a Date table, a Time table, and a data table. My data table contains one ticket per row with a timestamp.   I have broken out the time stamp into date, time, weekday and hour.  I have a day of week slicer that is connected to my date table ('Date'[Day of Week]) and a date slicer that is connected to my date table ('Date[MMYY]).
These are the measures that I am using: 
Total Tickets Countrows('Mytable')
Avg Per Day
AVERAGEX(DISTINCT('MyTable'[Date Created]),Calculate(Countrows('MyTable')/[Count Days]))

Count Days = DISTINCTCOUNT('MyTable'[Date Created])
Hourly Average = AVERAGEX(SUMMARIZE('MyTable', 'MyTable'[Hour],"Hourly Total",COUNTROWS('MyTable')),[Hourly Total])
 
The Hourly Average is where I am struggling.  The hourly average measure is actually giving me the totals per hour for the selected day where I need the hourly AVERAGE of tickets per hour of each day (for the slicer selected day(s) and Month(s).  
 
I tried Hourly Average = AVERAGEX(SUMMARIZE('MyTable', 'MyTable'[Hour],"Hourly Total",COUNTROWS('MyTable')),[Hourly Total])/[Count of Days] and that gives incorrect averages that do not add up. 
 
As a test, I tried manually adding in the count of days. and this works.  The averages per hour across the days is correct.   So All Saturday and Sundays in Jan, Feb, and March = 25. 
Hourly Average = AVERAGEX(SUMMARIZE('MyTable', 'MyTable'[Hour],"Hourly Total",COUNTROWS('MyTable')),[Hourly Total])/25. 
 
Here's what I get in excel and what I am expecting to see - Expected averages.JPG

How do I get this measure to work using the slicer selected days?
Power BI example.JPG
1 ACCEPTED SOLUTION
bevawn
Frequent Visitor

I finally got this to work!  Posting the solution here in case others have this issue.  At least this appears to function as expected. 

 

I changed the Count Days measure to be: 

Count of Days=CALCULATE(DISTINCTCOUNT('Date Created'[Date]),all('Date Created'[Date]))
 
Then my Per hour measure worked: 
AVERAGEX(SUMMARIZE('MyTable', 'MyTable'[Hour],"Hourly Total",COUNTROWS('MyTable')),[Hourly Total])/[Count of Days]
 
 
 

View solution in original post

3 REPLIES 3
upen
New Member

What is Hourly Total in your measure?

Is it count of hours or sum of hours?

tamerj1
Super User
Super User

Hi @bevawn 

Please try

Hourly Average =
AVERAGEX (
    SUMMARIZE ( 'MyTable', 'MyTable'[Date Created], 'MyTable'[Hour] ),
    CALCULATE ( COUNTROWS ( 'MyTable' ) )
)
bevawn
Frequent Visitor

I finally got this to work!  Posting the solution here in case others have this issue.  At least this appears to function as expected. 

 

I changed the Count Days measure to be: 

Count of Days=CALCULATE(DISTINCTCOUNT('Date Created'[Date]),all('Date Created'[Date]))
 
Then my Per hour measure worked: 
AVERAGEX(SUMMARIZE('MyTable', 'MyTable'[Hour],"Hourly Total",COUNTROWS('MyTable')),[Hourly Total])/[Count of Days]
 
 
 

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.