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 Like

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.

3 Likes

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.