How to make an array with totals ?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make an array with totals ?

ricetrac
Hi,

With the 2018.1 version, I look at the possibilities of the builder compared
to what you manually develop as a form.
And there is a need that does not seem to me covered by the builder: a
number chart with totals on the last line.

Our clients manage finances, and they need a table for entering financial
amounts and automatic totals at the end of the line.
I tried to do a repeat grid, but you can not include a footer with a total.

Is there another possibility?
Thank You.

julien

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: How to make an array with totals ?

Alessandro  Vernet
Administrator
Hi Julien,

If you have a repeated grid which contains an (repeated) input field named
`price`, you can have a field outside of the repeated grid that computes the
total with the expression `sum($price)`. If there is a chance that some
values aren't number (e.g. left empty) and you want to treat those as zeros,
you'll write the following (for more on this, see the link below):

sum($price[string() castable as xs:decimal], 0.0)

Is this inline with what you're looking for?

https://doc.orbeon.com/form-builder/formulas/formulas-examples#sum-of-values-in-a-repeat

-Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: How to make an array with totals ?

ricetrac
Hi Alex,

I did not see the example in doc. I was wondering if there was a component to do that. Because the rendering is not as good as if it was a footnote.
It's basically what I did, but how does the variable $price work? it's just the fact of putting a "price" id on the input fields? and $price gives access to the data? you do not have to build the xpath?

Thank You.

julien

-----Message d'origine-----
De : [hidden email] <[hidden email]> De la part de Alessandro Vernet
Envoyé : jeudi 20 septembre 2018 02:27
À : [hidden email]
Objet : [orbeon] Re: How to make an array with totals ?

Hi Julien,

If you have a repeated grid which contains an (repeated) input field named `price`, you can have a field outside of the repeated grid that computes the total with the expression `sum($price)`. If there is a chance that some values aren't number (e.g. left empty) and you want to treat those as zeros, you'll write the following (for more on this, see the link below):

sum($price[string() castable as xs:decimal], 0.0)

Is this inline with what you're looking for?

https://doc.orbeon.com/form-builder/formulas/formulas-examples#sum-of-values-in-a-repeat

-Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: How to make an array with totals ?

Alessandro  Vernet
Administrator
Hi Julien,

This is a feature implemented at the XForms level, in the model: having a `name` on the `xf:bind` defines a variable with that same name that you can use inside the model. If the bind points to multiple nodes, the meaning of the variable depends on where it is used: if from within the repeat it refers to the node in the "same iteration"; if from outside it returns all the nodes. (I'm simplifying things a little bit here, but you get the idea.)

And Erik created an RFE to have native support for "totals", or similar aggregate function, which would make things simpler and nicer:


-Alex

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: How to make an array with totals ?

ricetrac

Hi Alex,

 

It's really great this variable system via the bind. In production we do not use the builder, and it could very much simplify our life in Xforms. By cons, it is from which version of orbeon?...

Thanks for the RFE on the native support of the "total" ;)

 

Julien

 

De : [hidden email] <[hidden email]> De la part de Alessandro Vernet
Envoyé : vendredi 21 septembre 2018 01:15
À : Orbeon Forms <[hidden email]>
Objet : Re: [orbeon] Re: How to make an array with totals ?

 

Hi Julien,

 

This is a feature implemented at the XForms level, in the model: having a `name` on the `xf:bind` defines a variable with that same name that you can use inside the model. If the bind points to multiple nodes, the meaning of the variable depends on where it is used: if from within the repeat it refers to the node in the "same iteration"; if from outside it returns all the nodes. (I'm simplifying things a little bit here, but you get the idea.)

 

And Erik created an RFE to have native support for "totals", or similar aggregate function, which would make things simpler and nicer:

 

 

-Alex

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: How to make an array with totals ?

Alessandro  Vernet
Administrator
Hi Julien,

I'm not sure when it was introduced, but it has been in for a while; maybe around the 4.0 time? Try with the version you're using now, and it might have already been implemented back then.

-Alex

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet