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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
MyThumbsClick
Helper II
Helper II

1 to Many table relationship. Sum the many's and calculate average

Hi All
I have 2 tables linked: AllTickets and AllTimeEntries like below in a 1 ticket can have many time entries relationship.

MyThumbsClick_0-1714643114167.png

I am trying to figure out how I can visualize an average of the total time entries per ticket. Because there can be multiple time entries, I need to sum the entries per ticket first and then do the average.

 

For the below example, the answer would be 1hr 8m

 

Ticket 1

time entry 1 = 5m

time entry 2= 30m

Ticket 2

time entry 1 = 2hr

Ticket 3

time entry 1 = 20m

time entry 2= 30m

etc

 

Whats the best way to go about achieving this?

1 ACCEPTED SOLUTION

Hi @MyThumbsClick 

Yes, that is another measure as below :

 

 

Total Time Spent = 
SUM(
   'Time Entries Table'[time_spent]
)

 

 

 

Average Total Time Spent = 
AVERAGEX(
    VALUES(
        'Tickets Table'[id]
    )
    ,[Total Time Spent]
)

 

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards.

View solution in original post

8 REPLIES 8
h21
Helper I
Helper I

Hi @MyThumbsClick 

Is it possible for you to share the sample data and also an example of how you want output. 

It will be helpfull to work with sample data.

 

Thanks.

Hi h21

I "fat fingered" it and accepted your reply as the solution. Can you undo that?

 

Example Data:

Tickets Table:

subjectidprioritystatussourcecreated_atupdated_at
Example ticket 11948045124/04/202426/04/2024 09:36
Example ticket 21947925100224/04/202424/04/2024 09:27
Example ticket 31947825100224/04/202424/04/2024 09:27
Example ticket 41947725100224/04/202424/04/2024 09:27
Example ticket 51947625100224/04/202424/04/2024 09:27
Example ticket 61947525100224/04/202424/04/2024 09:27
Example ticket 71947425100224/04/202424/04/2024 09:27
Example ticket 81947325100224/04/202424/04/2024 09:27
Example ticket 91947225100224/04/202424/04/2024 09:27
Example ticket 101947013224/04/202429/04/2024 12:57
Example ticket 111946922100124/04/202424/04/2024 08:00
Example ticket 121946822100124/04/202424/04/2024 10:20
Example ticket 131946715100223/04/202423/04/2024 22:02
Example ticket 141946624123/04/202429/04/2024 09:50
Example ticket 151946525100223/04/202424/04/2024 08:58
Example ticket 161946425100223/04/202426/04/2024 14:35
Example ticket 171946335123/04/202426/04/2024 09:36
Example ticket 181946115223/04/202425/04/2024 17:35
Example ticket 191946025100223/04/202423/04/2024 17:07
Example ticket 201945925100223/04/202426/04/2024 11:35
Example ticket 211945615223/04/202425/04/2024 16:35
Example ticket 221945512223/04/202429/04/2024 11:48
Example ticket 231945415223/04/202424/04/2024 11:20

 

Time Entries Table:

ticket_idtime_entry_idtime_spentexecuted_atworkspace_idagent_id
194805200088173200:0524/04/2024 09:27252000034458
194705200088203800:2024/04/2024 10:10252000014474
194665200088733500:1025/04/2024 16:30252000014461
194665200088893800:3026/04/2024 11:00252000014461
194665200088257701:1524/04/2024 10:15252000014461
194645200088324500:1024/04/2024 13:51252000034459
194635200088142900:1024/04/2024 08:44252000014474
194615200088073700:0523/04/2024 17:30252000034458
194595200088361900:0524/04/2024 15:02252000034459
194595200088150800:3024/04/2024 17:30252000034456
194595200088239400:3024/04/2024 11:02252000034456
194595200088151501:0023/04/2024 17:00252000034459
194595200088239300:3024/04/2024 10:30252000034459
194565200088056600:0523/04/2024 16:31252000034458
194555200088150000:3024/04/2024 17:00252000034456
194555200088377400:3024/04/2024 15:00252000034456
194555200089259603:0029/04/2024 09:00252000034456
194545200088027700:1023/04/2024 15:32252000034458

(I have removed some columns to keep charecter count down.)

 

Im trying to create a measure that displays the average total time spent on tickets on a card visualisation.

Hi @MyThumbsClick 

 

Do you want something like below: 

ticket.png

Thanks for this. What is [Total Time Spent]? Is that another measure? 

Hi @MyThumbsClick 

Yes, that is another measure as below :

 

 

Total Time Spent = 
SUM(
   'Time Entries Table'[time_spent]
)

 

 

 

Average Total Time Spent = 
AVERAGEX(
    VALUES(
        'Tickets Table'[id]
    )
    ,[Total Time Spent]
)

 

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards.

Thanks. I think i have 1 issues:

 

A slicer on the page is interefing with the visual/measure and i just get (Blank). The slicer is scoped to Tickets Table[created date]. If i exclude the interaction with the visual/measure, I get a result. I do want to keep the slicer though because i want to slice based on when the ticket was created.

Hi @MyThumbsClick 
 Is that issue is happening everytime when you selecting the slicer or for some selection of the slicer only. 
Or other way is you can try plotting the data from the Date Table you have created or if you haven't created the Date Table. Than for once, try plotting the date from the Date Table. 

Best Regards.

Hi @MyThumbsClick ,

 

I can't undo the action for the solution. That will be undo by you only.

Thank you for sample data. 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.