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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Sof
Frequent Visitor

Average where not all values are present

I have two columns, one with date-time values rounded to the hour and one an ID that is present at that time. This looks like:

DATETIME                         ID

2015-01-06 15:00:00        1

2015-01-06 16:00:00        1

2015-01-06 16:00:00        2

2015-01-06 18:00:00        3

2015-01-06 19:00:00        3

I have grouped them per hour and per day. I now want to calculate the average number of ID's present per day. However, because sometimes there are no ID's present, it doesn't count those times as 0. For example when 1 ID is present for half of a day, it will put the average on 1 instead on 0,5. My average is thus way to high. How can I solve this? 

1 ACCEPTED SOLUTION

The problem is that there is no dataline when no ID is present. I solved it by not using the standard average function, but by calculating the average using the DATEDIFF to calculate the number of DATETIMEs in the interval between MIN(DATETIME) and MAX(DATETIME).

View solution in original post

2 REPLIES 2
vanessafvg
Super User
Super User

@Sof what does your data look like when no idea is present?

 

like so?

 

DATETIME                         ID

2015-01-06 15:00:00        

 

you could always create an index column which will present a value for each datetime, in power query add a index column and then do the average on that rather

 

or you could create a calculated column in dax 

if(isblank(id), 0, id)

 

think the index column might be easiest if you just trying to get a count for each row

 you could also do the average of a countrows

what does your measure look like?





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!




The problem is that there is no dataline when no ID is present. I solved it by not using the standard average function, but by calculating the average using the DATEDIFF to calculate the number of DATETIMEs in the interval between MIN(DATETIME) and MAX(DATETIME).

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors