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
ChromeMystic
Helper I
Helper I

Total Login Time per Agent (More than 24 hours)

Hi, I am still pretty new to Power Bi and I m currently trying to change our old Excel Dashboard to Power BI. One of the Reports we use gives a value of hh:mm:ss for each day on how long every agent was logged into the system. After a lot of swearing (The Original Report comes from a system that adds all kinds of weird formating that I had to remove, and we have no way to export it directly in a usable format, so I wrote a macro to remove all the weirdness and export a clean file).
I converted the Entries to durations and now I am trying to build a visual that gives me the Total of hours the agent worked this month (for now I only use a 1 month report so that I don't need an aditional Date filter).
I spent the last 5 hours searching these and other forums and watching tons of tutorials and the best i managed is the following measure

LoginTime = FORMAT(SUM(Agent_Login[@RCW_LoggedInTime]);"hh:mm:ss")

It seems to calculate the sum correctly, but I cannot get it to give me a accurate total, it basically omits the days.
In Excel I solved this by using the "[hh]" format but this isn't available in Power BI

During my search I found several proposals that had formulas of more than 20 lines or so but neither was I able to change them in order to work for me and also it seems weird to me that I need to write this much code just to add up some time.

Any tips on where to look or how to do what I need to do are appreciated.

1 ACCEPTED SOLUTION

I managed to solve my problem - i converted the Timestamp into seconds

LoggedInSeconds = DATEDIFF(DATE(1899;12;30);Agent_Login[@RCW_LoggedInTime];SECOND)

In order to get the views I need I used the Script from https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486 with 

 

SUM(Agent_Login[LoggedInSeconds])

I could also combine the two into 

SUM(DATEDIFF(DATE(1899;12;30);Agent_Login[@RCW_LoggedInTime];SECOND))

but I chose not to, as I can use the LoggedInSeconds in order to do quick checks of my calculations

View solution in original post

4 REPLIES 4
ChromeMystic
Helper I
Helper I

I managed to use the script in https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486 to create a new column, now PowerBI tells me that it cannot convert text....

Hi @ChromeMystic 

Sample data and expected output will be helpful to provide an accurate solution.If you need further help,please follow the How to Get Your Question Answered Quickly to post your simple assumed data and expected output.

Regards,

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

After hours of trial and error I forgot basics of asking for help. Now I am back at the Office and here are some additional Infos.

 

The Query I use is named "Agent_Login" and it imports the data from our Phone System. After cleaning up the data it looks like this:

 

@RCW_AgentName@RCW_LoggedInTime@RCW_Timestamp
Name109:07:3801.06.2019 00:00
Name208:27:4801.06.2019 00:00
Name307:06:5601.06.2019 00:00
Name407:10:1001.06.2019 00:00
Name509:01:2501.06.2019 00:00
Name607:59:3202.06.2019 00:00
Name509:08:4902.06.2019 00:00
Name608:49:0802.06.2019 00:00
Name706:58:2902.06.2019 00:00
Name807:16:4602.06.2019 00:00
Name908:59:4603.06.2019 00:00
Name1008:05:17

03.06.2019 00:00

 

I saved the Report as .csv before Importing it into Power BI.

 

I would like to calculate things like how many hours did all our agents log on a given day or how many hours did a single agent log over the course of a month. As I described before I can't get it to work with durations > 24hours. 

The Column @RCW_LoggedInTime is Formatted as Duration and the @RCW_Timestamp as Date. I also renamed them Inside Power BI to make them conform with the reports I get from the other systems (Timestamp was renamed to "Date" for instance).

My expected Outcome would be that when I get a report over all logged hours on the 02.06.2019 the Total  would add up to 81:06:41. At the Moment I either get errors and no results at all or 09:06:41

 

Edit: I forgot to mention, that the Timestamps of the Duration are shown as decimals in the Table view unless I manually change them to "time": 

2019-07-25 10_03_44-Window.png

I managed to solve my problem - i converted the Timestamp into seconds

LoggedInSeconds = DATEDIFF(DATE(1899;12;30);Agent_Login[@RCW_LoggedInTime];SECOND)

In order to get the views I need I used the Script from https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486 with 

 

SUM(Agent_Login[LoggedInSeconds])

I could also combine the two into 

SUM(DATEDIFF(DATE(1899;12;30);Agent_Login[@RCW_LoggedInTime];SECOND))

but I chose not to, as I can use the LoggedInSeconds in order to do quick checks of my calculations

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.