Sum or +

When do I use + and when do I use SUM(LIST()) ?

Is one more efficent over the other or is it equivalent?

My understanding:

When adding the individual columns of either of number, decimal or price type you could use +

For example, if you have [Initial Quantity] and [Added Quantity], each as number type columns, you could do [Initial Quantity]+ [Added Quantity]. As long as those individual columns evaluate to a number or price or decimal type you could use +

The above can also be computed as SUM(LIST([Initial Quantity], [Added Quantity])) but mostly one will prefer just to add those individual columns with a +

So you could even do ANY(Some Table[Quantity]) + ANY(Other Table[ Another Quantity]) because ANY() extracts a single value from the list.

Alternatively, if you get/ retrieve a combined list of number, decimal or price type several values through say a SELECT() statement, to add those elements in the list, you could use SUM(SELECT(…))

Edit: Added some more description.

2 Likes
  1. I would say that if you are making an addition in the context of a row and it’s columns (which are a fixed qty of columns * 1 row) use β€œ+”
[Col1]+[Col2]+[Col3] on a VC called like "[Sum]"
  1. If you are making an addition in the context of multiple rows (list of values) of one column, use SUM()
SUM(Dataset[Column]) on a VC called like "[Sum]"
  1. If you are making an addition in the context of multiple rows on multiple columns, you can use both:
  • For example, if you did the first thing, you can then sum those again but for all the rows of a certain dataset
Dataset[Sum]
  • If you did the second one and you want another column:
SUM(Dataset[Column])+SUM(Dataset[OtherOne])

In general use SUM() if there is a list which may have an unknown number of items and β€œ+” when you want to make basic additions of a fixed number of fields

3 Likes

@SkrOYC @Suvrutt_Gurjar Thank you :slightly_smiling_face:

2 Likes

Please note that β€˜+’ is also used in AppSheet as a list addition operator.

List Addition | AppSheet Help Center

2 Likes