How can I perform more complicated math in database?

Hi!

I'm quite new to SiYuan. I have selected it out of 7 other note taking app as my go-to one due to it being free, open-source, and so feature-rich.

I have discovered database template, which allows me to f.e. sum, substract, multiply, etc. several columns together. Here is my example database.

image.png

I need to perform a chain operation on the first column, so that it is first divided by 2, then substracted by 5. I already tried:

  • .action{div .Score 2} .action{sub . 5}

  • .action{sub {div .Score 2} 5}

  • I tried to split calculation into two columns: The first divides .action{div .Score 2}, the second substracts .action{sub .HalfScore 5}, but for some reason the last column cannot grab a value of HalfScore and always substracts from 0

    None of these seem to work. Golang documentation suggests writing a separate function, but how can I write a function and use it in SiYuan?

    On another Note:

    Is it possible to calculate values in non-database blocks? Like I have block A with a value, then another block B, and I want to f.e. sum both values and put them in block C. Or look up value A into block C. Is this possible?

    Thanks in advance!

    Welcome to here!

    Here we can learn from each other how to use SiYuan, give feedback and suggestions, and build SiYuan together.

    Signup About
    Please input reply content ...
    • zxhd86

      Currently, template columns cannot be referenced to each other.

      I'm afraid that writing a function will require modifying the source code of SiYuan, which is the case with the week function contributed by the community before.

      The last requirement may not be fulfilled.

    • Eric
      Author

      Thanks for the reply! I'll find another way then! 👍