cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

Accepted Solutions
Highlighted
Microsoft
Microsoft

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

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
Highlighted
Microsoft
Microsoft

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

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.
Highlighted
Frequent Visitor

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

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. 

Highlighted
Microsoft
Microsoft

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

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

Highlighted
Frequent Visitor

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

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Upcoming Events

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors