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
eugee123
New Member

Count number of logins in an hour per day

Hi, I have a bunch of login and logout dates and time (raw data). I would like to trend the number of logins per hour (eg, 1am to 2am), per day (was thinking to add this as a slicer to filter the dates).

 

eugee123_0-1627895992647.png

 

I have created 2 DAX formulas,

 

1 to create a new table based on hours

 

1) 

Table = GENERATESERIES(HOUR(MIN('52114L3M1M1'[Login Time])), HOUR(MAX('52114L3M1M1'[Logout Time])))
 
The other to count the number of logins at each hour
 
2) 
Operator Log On = CALCULATE(COUNTROWS('52114L3M1M1'), FILTER(ALL('52114L3M1M1'), HOUR('52114L3M1M1'[Login Time]) <= 'Table'[Time (HR)] && HOUR('52114L3M1M1'[Logout Time]) >='Table'[Time (HR)]))
 
However, with this, I am unable to slice the data based on various dates, as it just adds up the number of logins at each hour for all the dates in my dataset. Could someone kindly advise how to create a relationship between my 2 tables such that i can slice the data based on various dates? Thanks
 
eugee123_1-1627896348397.png

 

7 REPLIES 7
v-jayw-msft
Community Support
Community Support

Hi @eugee123 ,

 

Has the porblem be solved?

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
eugee123
New Member

Thanks! Can i get some help on how to include the day in the first formula?

lbendlin
Super User
Super User

You're on the right track but there are some caveats.

 

your formula for 1)  doesn't work when the login hour is later than the logout hour.  You must include the day in your consideration.

 

GenerateSeries is the right approach though. For each visual row you need to generate a series of hours covered by that row (might be just one hour, but the idea is the same).  Then for EACH login you need to generate the series of hours covered by the interval the user was logged in. Then you need to take ALL these intervals and INTERSECT them with your visuals hours range, and count the matching rows. That will tell you how many users were logged in during that visual row interval.

 

There are many more caveats but this should get you going.

Thanks! Can i get some help on how to include the day in the first formula?

Table = GENERATESERIES(MIN('52114L3M1M1'[Login Date])+INT(MIN('52114L3M1M1'[Login Time])*24),MAX('52114L3M1M1'[Logout Date]) +INT(MAX('52114L3M1M1'[Logout Time])*24))

Thanks, but this only results in a column with all the dates, and the timings are only 00:00 hours. I require the timings from 0000 hours to 2300hours. Eventually I hope to be able to get this graph to trend the logins per hour per day. 

 

eugee123_0-1627970325391.png

 

Yes, my bad. You need to first add Date and time, then multiply the sum by 24 and then take its integer value.

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.