Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: timonkIain,
I am assuming you are referring to the Excel SUMPRODUCT function?
Have you considered the list functions "map" and "reduce"?
Take a look at this example code. You can drop this into a filter.
product = map(&*, list(1,2), list(100,200)) #multiply the list elements, return list of results
sumproduct = reduce(&+, product) #sum the ilist of results
emit str(sumproduct) as SP, str(product) as P
You will get
SP:string P:string
500 {100;400}
And of course you can nest these functions:
reduce(&+, map(&*, list(1,2), list(100,200)))
Perhaps these can help? You can use the Aggregate node to create lists out of input columns.
Here's just a quick example. Say you have input columns "A" and "B". We can create lists of them like this:
==========================
if firstInGroup then my_list = list(A)
else my_list = append(my_list, A)
if firstInGroup then my_list = list(B)
else my_list = append(my_list2, B)
emit str(my_list) as newlist_A, str(my_list2) as newlist_B
where lastInGroup.
###GroupBy value
true
============================
Then you could just apply the map/reduce from above.
Just a suggestion. Does this help?
Regards
Timon Koufopoulos
MDA Support.