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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
stephenroos
New Member

How to count number of visits depending on hour visitor arrived.

Hi all,

 

I'm trying to do a count from a time column where i add up the number of visitors that arrived during a specified time period.


For example I want to capture the number of visits between 07:00 - 14:59, 15:00 - 22:50 and 23:00 - 06:59 however I can't use the countif formula like I can in excel.  Does anyone know how I would accomplish this in PowerBI?  

 

Thanks for any help.  I've been stuck on this for a few days now..

 

1 ACCEPTED SOLUTION

it should work, once mistake in my formula whcih is fixed now

 

hour range = 
var x = hour(yourtable[yourdatetimecolumn])
return if(x >= 7 && x < 15, "07am-15pm", if(x >= 15 && x <= 23, "15pm-23pm", "00am-07am")) 


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

add a new column something like below to get hour range and use this new column on x axis on your chart:

 

hour range = 
var x = hour(yourtable[yourdatetimecolumn])
return if(x > 7 && x < 15, "07am-15pm", if(x >= 15 && x <= 23, "15pm-23pm", "00am-07am")) 


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

That's fantastic!!  Thank you so much!!  Is there any way to set it to 06:59 so I'm not capturing any entry at 07:00 twice ?

it should work, once mistake in my formula whcih is fixed now

 

hour range = 
var x = hour(yourtable[yourdatetimecolumn])
return if(x >= 7 && x < 15, "07am-15pm", if(x >= 15 && x <= 23, "15pm-23pm", "00am-07am")) 


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you so much.  Means a lot.  

Saved me a lot of headache.

@stephenroosno worries buddy, glad to hear it worked out, feel free to reach out any time.

 

cheers,

P



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

scign
Frequent Visitor

You could also use the 'groups' feature.

 

If you right click a text field and select 'New Group' you'll be able to select how the various text values are grouped.

 

However if you do the same with a numeric field, you can set up 'bins' which can be set to intervals, or automatically calculated intervals based on the number of bins you want. This works for time periods too.

 

Since you want your 8-hour bins to be offset from midnight, you might need to start with auto-calculated 1-hour bins, then manually group THOSE BINS, with 00:00-01:00 to 06:00-07:00 as well as 23:00-00:00 being in the same group, and splitting the rest between two other groups.

 

You should end up with 3 groups of 8 bins each - hope that's not too confusing! I would have added screenshots but not sure how to...

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors