Action to write value summed from children tests fine but return zero

Hello,

In my attempt to optimize my apps , today I replaced some spreasheet formula with an appsheet action button, to write in a parent column the sum of a child table column (set values in this row) , something like

[ParentColumnSum]=sum([RefColToChild][ChildQuantity])

When testing the formula, results were perfect in testing page.
When using the action, it wrote 0 in my spreasheet.

I rewrote the action using select instead of child referencing

[ParentColumnSum]=sum(select(etc…)) , and it works just fine.

There were no slices, no security filters, so my question/curiosity is why the first version of action tested correctly but wrote zero in spreasheet.

Thank you for helping me understand

I just setup what I believe is the exact same thing, and it works as expected for me:

image


image

I’d assume the answer as to why it didn’t work for you lies somewhere else.

1 Like

In my experience, the Related … virtual columns are unreliable. Use SELECT() instead as you have.

2 Likes

Really? Any ideas why, or under what circumstance? I’ve used them a lot and can’t recall a single instance where they didn’t work as above.

@WillowMobileSystems this is related to what you were asking in that thread the other day, although still no solid answer.

1 Like

I’m intrigued too. It happened to me once before , but that time I was using the filter all rows option, so they were filtered out before the action triggered

I just saw, you are summing the keys from children, I was summing another column in children. I will study if this has any effect

This might be what I was thinking of - usage of “Related” columns. The post you mention was about the similar shorthand for tables.

I have had instances where referencing related columns (like in the SUM above) didn’t work in very complex expressions. What I did instead of a whole other SELECT(), was to assign a virtual column to the shorthand expression. For instance, in the SUM expression above I would do this:

New Virtual Column = [RefColToChild][ChildQuantity]

Then I would write the summation as SUM([New Virtual Column])

1 Like

The VC technique worked in my case too, while testing options. My end goal being speeding up, I avoided VC .

Still, it’s the simplest expression, so in theory the VC should not be needed

Agreed!!

Be careful on how you analyze which is faster in this particular use case - VC or SELECT(). It will depend on where the SUM happens and how big the table is.

Thank you. My action is a manual only one (button), rarely used, so I preffer the speed up sync