The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Math Calculation

Labels

This Discussion is public

Notifications

Good day,

I have a query and I’m hoping someone can shed some light on how to go about it, or if anyone has done similar before and has a work around.
I have a form that a user can enter statistical data (numbers) for different periods of the day.
The form has a checkbox function with conditionals set that populates the fields relevant to that period of day for the user to enter the data
When submitted the data is passed through the URL, however I believe that this or the [frm-field-value field_id=4926 1493="[id]"] would be suffice. To pull in the values submitted.
I can get the values but I need to perform a maths calculation, and this is where it’s getting tricky for me.
I can use the math short code to calculate multiple values, but the problem I have is if the user is to select more than one option from the form I get a blank entry in the view.
I need to look for a work around that allows the user to select as many of the options they need to then perform the calculation based on them.

As you can see the + operator is between the conditionals which appears to break the calculation, then not only that if I add the operator within the conditional statement like this:

Then this also breaks if one of the options are not selected from the checkbox

Is there a way that I can use the + operator at the end of each parameter statement based on selections of the checkbox but not the end parameter so it does not break the calculation?

Many thanks Chris

[frm-math][if get param=b3restes not_equal=""][get param=b3restes][/if]+[if get param=b3restes not_equal=""][get param=b3restes][/if][/frm-math]
As you can see the + operator is between the conditionals which appears to break the calculation, then not only that if I add the operator within the conditional statement like this:
[frm-math][if get param=b3restes not_equal=""][get param=b3restes]+[/if][if get param=b3restes not_equal=""][get param=b3restes][/if][/frm-math]

I have a few questions. Your process isn't clear to me.

When you say "When submitted the data is passed through the URL". Are you creating a query string when a form is submitted and the entry is created? Why? What is the next step in the process that is reading the values of the query string? Or are you trying to build the query string on the fly when a user clicks on the link to open a view. Please explain exactly what you are doing to build the query string and when.

Both sides of your math calculation are identical. Are you really trying to read the same parameter twice and add the value to itself?

It would also help to have a visual. Can you possibly post a link to the form and/or view? If not, can you post screen captures?

Hi Victor,

Apologies, after sitting here for hours on end, i was trying to conditionally calculate values based on user selection from select box.

I believe i have it working now with the basic [fields-stats] shortcode. I dont know where my head was when using the [frm-math] shortcode as it wasnt required.

Thanks for replying

 

Chris

Discussion closed.