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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bpopp
Frequent Visitor

Using Calendar Table to Count Hourly Transactions (without missing hours)

I'm sure this is a common problem, but I've searched in vain for several hours. I have a calendar table and a transaction table. Each transaction has a calculated datetime for the start of the hour (ie. 3/4/2017 03:00:00) and this is related to a calendar table containing a datetime calculation for each of the 24hours in each day. I created an inactive relationship (Actual On Hour) tying the two tables together and used a measure to count the related records:

 

Actual Flights Per Hour = Calculate(COUNTROWS('Flights'),USERELATIONSHIP(Flights[Actual On Hour],'Calendar'[DateTime]))

 

This works fine:

 

2018-08-14 09_59_33-impact - Power BI Desktop.png

 

but the problem is that I'm only getting records when there are matches. What I would like to see is every hour of every day, with zero's for the records where there are no relationships. Also, is there a way to do this without creating a relationship? I have four different dates and would prefer to not have to build inactive relationships for each.

 

Thanks so much,

 

bpopp

1 ACCEPTED SOLUTION

Hi @bpopp,

 

You can enable the option "Show items with no data" for the date column that is added to Matrix row.

1.PNG

 

Also, make a little adjustment to your original formula:

Actual Flights Per Hour =
CALCULATE (
    COUNTROWS ( 'Flights' ),
    USERELATIONSHIP ( Flights[Actual On Hour], 'Calendar'[DateTime] )
)
    + 0

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @bpopp,

What I would like to see is every hour of every day, with zero's for the records where there are no relationships. 

 

What do you mean "with zero's for the records"? How are these records look like? Please provide sample data of 'Flights' table to better describe your scenario.

How to Get Your Question Answered Quickly

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

In the example above, there were no matches for 8/13 2:00, so it just skipped it and went to 8/13 3:00. What I want is for it to include 8/13 2:00 with the count for that hour set to zero. 

Hi @bpopp,

 

You can enable the option "Show items with no data" for the date column that is added to Matrix row.

1.PNG

 

Also, make a little adjustment to your original formula:

Actual Flights Per Hour =
CALCULATE (
    COUNTROWS ( 'Flights' ),
    USERELATIONSHIP ( Flights[Actual On Hour], 'Calendar'[DateTime] )
)
    + 0

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I must have seen that a million times and just didn't notice it. Thanks for the help.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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