Summing Up Enum List Selection

I have below tables:

  1. Service Details: Contains all services with price & other different attributes.
  2. Service Availed: Is the table where I basically select the services I want to book.

So, service availed table has a field by the name of service name which is of enum data type. I want the sum of service charge from the service details table for only the services selected in the service availed table, keeping in mind the pet size & pet coat in mind.

I tried the below formula, ignoring the pet size and pet coat attribute for now just to see if I am able to atleast get a sum, but it didnt work.

SUM(
SELECT(
Service Details[Service Charge],
IN([Service Name],[_THISROW].[Service Name])))

Can someone help?

It may be wise to create virtual columns for each of the charges and then create a virtual columns with a sum of “Charges” by the date or ID for service details.

SUM(SELECT([Service Details][AMOUNT], [Service Charge] = “Pet Coat”))

SUM(SELECT([Service Charges][AMOUNT], TRUE))

Default the value for each charge as 0

It would help if you could post views of the tables involved

I didn’t understand. Creating a virtual column for each charge? How would that help?

How didn’t it work? How did you implement this? Please post a screenshot of the configuration.

1 Like

Hi Steve

Do you mean the tables?

Sorry, of the computation. The expression you posted looks fine to me, so I’m interested in figuring out why it didn’t meet your needs.

1 Like

It would help if you could post views of the tables involved

1 Like

@Steve please see if this help?

1 Like

Please also post screenshots of the columns for both of the involved tables.

1 Like

Service Details Table:

1 Like

Hmmm… Seeing nothing wrong. Please post a screenshot of the configuration of the Service Name column of the Services Availed table.

Here it is

1 Like

You are trying to compare that Service name is part of your EnumList. The EnumList contains key values as you are using the base of Ref. Because the “Service name” is not the key column, it doesn’t find it from the list. You need to use..

SUM(
SELECT(
Service Details[Service Charge],
IN([Service ID],[_THISROW].[Service Name])))

2 Likes

Yes Aleksi, this worked. Understood my mistake. Thank you Steve for the efforts.

2 Likes

Good to hear!

2 Likes