Query table function sum not working

i have a block template to calculate tea expense.
-[[tea and snacks expense]]

I normally create blocks with this template in the journals page daily.

when I query with
{{query(and [[tea and snacks expense]] (between [[Mar 26th, 2023]] [[Apr 25th, 2023]] ))}}
it returns query table

and I use a query table function below it as a child block to the above query
{{function (sum :amount)}}
logseq does not return the total amount. what could be the reason?

It was working before, but now its not working.


Hi there,

I suggest hopping on this bug report in GitHub. Query table function `sum()` not work · Issue #9173 · logseq/logseq · GitHub

This issue #9563 has not been fixed completely. I have been waiting patiently for the bug fix; but when I saw it was marked complete; I wondered whether it was intentional to partly fix it or was missed. I’m using the latest version and still facing the issue.

Although individual sum, average functions are working; this is not working:
{{ function (+(sum :x) (sum :y))}}

Have you tried without a space between {{ and function ?

yes, and didnt work.
It just shows a long string of concatenated numbers from the property values

It works for me. If at least one of the values of the properties is a string itself instead of a number, it ends up like you said. Have you tried your query in a small dataset (preferably in a new graph), where you can quickly check each value?

1 Like

Thanks @mentaloid for the clarification. My functions used to work earlier and stopped since 0.9.1 or so. I updated the empty fields to 0 and they gave a good result. Probably related to db structure changes.
Thanks again!!