SUM Time

Hello

I have two tables (Order, Services).

When i do an orden and add services, I need to know the total of time of services.

How can i do it?

1.png2.png)

Solved Solved
1 3 76
1 ACCEPTED SOLUTION

Assuming your Time column is of Duration type and [Services] of ENUMLIST, then you can get the total duration by

SUM(
 SELECT(
  SERVICES[TIME],
  IN([SERVICE],[_THISROW].[SERVICES]
 )
)

 Another thing I noticed is that [SERVICES] collects labels rather than IDs of the SERVICES table. This may not be a big issue here immediately but, I would change it to ENUMLIST, Ref to SERVICES in the long term.

View solution in original post

3 REPLIES 3

Assuming your Time column is of Duration type and [Services] of ENUMLIST, then you can get the total duration by

SUM(
 SELECT(
  SERVICES[TIME],
  IN([SERVICE],[_THISROW].[SERVICES]
 )
)

 Another thing I noticed is that [SERVICES] collects labels rather than IDs of the SERVICES table. This may not be a big issue here immediately but, I would change it to ENUMLIST, Ref to SERVICES in the long term.

Appear this error   "  The 'SUM' function requires a list of numeric inputs  "

Your [TIME] column should be of type Duration as I already mentioned.

Then SUM() calculates the column properly as can be seen here.

TeeSee1_0-1714003595944.png

Top Labels in this Space