Support is currently limited. Click here to see our hours of operation.
Help Desk

Finding Average Value From User Specific Repeatable Forms

Labels

This Ticket is public

Notifications

Hello,

I am stuck in finding a solution to a math problem. I have a form with a repeatable section, inside this repeatable section I have a field (let's call it Field Goal Yards) that asks the user to enter a number of how many yards kicked in a year.

Because this is a repeatable section the user can have just one entry (for one year) multiple entries (year 2, year 3, year 4 etc) depending how many times he or she repeats this section. I am trying to display the lifetime average for this particular user, but I am getting the wrong answer.

I am using [frm-stats id=2857 type=average] to display the average but this is giving me the average of ALL the users who entered yardage in this field. I just want to display the career average yardage for a particular user.

Testing this out "User A" has entered 15 and 22. User B has entered 6 and 5.

Using [frm-stats id=2857 type=average] will show 12 as the answer (15+22+6+5=48 / 4 = 12) which is wrong.

It should be for "User A", 18.5 (15+22=37/2=18.5) And for "User B", 5.5 (6+5=11/2=5.5)

How can I get the correct average amount per user specific?

 

 

Hi --

The stats shortcode has a user_id parameter that allows you to specify the user and only compute stats for that user.

[frm-stats id=x type=count user_id=current]

You can read about this here:

https://formidableforms.com/knowledgebase/add-field-totals-and-statistics/#kb-user_id

You can use "current" to get the current user's stats.  Or you can put in a user id.  You want the user ID (number) not the username.  You can put in a specific number (e.g. 1) or get the number from a field.

If you're in a View, you can use a User ID field to get the User ID (number).  The User ID field stores the number but displays the username, so to get the user ID (number), you can use [100 show="id"], where 100 is the id of the User ID field.

Hi,

I am still a little confused.

When I enter [frm-stats id=2857 type=average user_id=current]  in a view that "User  A"  or "User B" is looking at their own record it shows up correctly.

But if "User B" wants to look at "User A" it shows "0".

How can I add the User ID  to [frm-stats id=2857 type=average user_id=current]

Lets say my User ID is 806 how can a view show the average of "User A" or "User B"?

I tried [frm-stats id=2857 type=average user_id="806"]  which does not work.

I understand that if I enter [806 show="id"] is correctly shows the specific user's id but how can I incorporate this to show the average? I still don't get it.

Hi --

I'm assuming you're in a View and 806 is the id of the User ID field in that View.  Please let me know if either of these assumptions is incorrect.

What happens when you try the shortcode below?

[frm-stats id=2857 type=average user_id="[806 show="id"]"]

Hi,

I got it.

Entering it as [frm-stats id=2857 type=average user_id="[806]"]  made it work.

Thank you for pointing me in the right direction.

 

Hi --

The way I gave you also works.  I'm glad to know that it works both ways.

Ticket closed.