• Resolved amweb1969

    (@amweb1969)


    Hi, I am trying to add a computed field in my table; the result should come from the difference between a single value in table1 and the sum of other values in table2, where table1.fieldvalue = table2.fieldvalue.
    I can obviously build a relationship (table join), but how can I query the result and insert the value in the “computed” field?
    Thanks
    Monica

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Kim L

    (@kimmyx)

    Hi @amweb1969,

    If all columns are already present in the table (using your joined table as the data source), your entry in the computed field will look something like:

    {:col1} - ({:col2} + {:col3})

    The calculation above will return the exact result. Just replace col1,col2, col3 with your column headers. ☺️

    Let us know how it goes.

    Thread Starter amweb1969

    (@amweb1969)

    Thanks Kim, but most probably I wasn’t able to explain correctly what I want …
    This is the query that I need to fill the field ‘difference’ (the best option would be if ‘difference’ is a computed field):
    table1.field –
    (
    SELECT SUM(table2.amount)
    FROM table2
    WHERE table2.id_project = table1.id_project
    )

    Thanks again
    Monica

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Thank you for the additional information, Monica.

    If I understand your requirements correctly, you want to access the parent data in your computed field. Because this data is not directly available in a computed field, you must first save it in your postQuery before using it in your computed field.

    We made an example because other users might find it interesting as well. The example is available here:
    https://docs.rad.wpdataaccess.com/tutorials/technical-tutorials/use-parent-data-in-computed-field.html

    Hope this helps. Please let us know if you require further assistance.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.