Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
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?
Solved! Go to 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).
@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?
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).
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.