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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
AndHan
Frequent Visitor

Hourly Average based on selected days

Hi all

 

I'm having some problems when I try to show the average number of events throughout the day based on number of selected days.

I've created 2 measures:

- One that sums all my events

- One that calculates number of days selected

 

The measure that calculate the number of selected days seems to calculate the correct answer (in this example 3), but when I divide my data with this measure it seems like it doesn't work as I expected. I have highligted where it goes wrong.

 

What am I doing wrong? 

When I try to just divide my measure with the data with the number 3 it looks like expected.

Example.PNG

6 REPLIES 6
Anonymous
Not applicable

Hi @AndHan 

I don't particularly understand the data you provided .What is the 'Date'[Date] ?

Could you provide a sample that may help us to deal with your issue easier .

 

Best Regards

Community Support Team _ Ailsa Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous

The 'Date'[Date'] is from my Date table - it's used on a date picker in my report. 

It returns the number of days selected, so I can use it to calculate the average pr. day.

 

Hope it makes sense 🙂 

AndHan
Frequent Visitor

Anyone who has any suggestions on how to fix this? 🙂 

AndHan
Frequent Visitor

And here's some sample data (csv):

Data.personCount,Data.ts,Dato,Time
16,19-05-2021 11:07,19. maj 2021,11
24,17-05-2021 11:11,17. maj 2021,11
19,18-05-2021 10:17,18. maj 2021,10
17,18-05-2021 11:40,18. maj 2021,11
14,17-05-2021 13:24,17. maj 2021,13
13,17-05-2021 13:14,17. maj 2021,13
12,19-05-2021 09:50,19. maj 2021,9
11,17-05-2021 11:21,17. maj 2021,11

vanessafvg
Super User
Super User

can youp provide your measure code and share some sample data?  please show what you are expecting.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Here is what I'm expecting to see (the dark blue is what i'll end up visualizing):

expected.PNG

 

The two measures I'm trying to use looks like this:

 
Timefordeling = CALCULATE(SUM(data[Data.personCount]))
 
Number of Days =
VAR a =
FIRSTDATE ( 'Date'[Date] )
VAR b =
CALCULATE ( MAX ( 'Date'[Date] ) )
RETURN
DATEDIFF ( a, b+1, DAY )

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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