[SOLVED] Calculating The Average and Percent Difference In A Column in a Repeater Data Set

Hi All,

I have a question related to running calculations in and Axure repeater. I’m trying to run the average of a particular column in a repeater. I then would like to use that average in another column for the repeater to create a benchmark of sorts. Column_1 refers to the column that I would like to calculate the average for and Column_2 is the benchmark.

Column_1 | Column_2
2        |  100*[(2-3)/3] = -33.33%
2        |  100*[(2-3)/3] = -33.33%
3        |  100*[(3-3)/3] =   0.00%
5        |  100*[(5-3)/3] =  66.67%

average_c1 = 3

There doesn’t seem to be an easy way to calculate the average. Can anyone help me out here? Thanks!


You can accomplish this using the listener technique, which I describe briefly in the file. This technique involves moving a widget in the repeater to force that widget’s OnMove event to fire. Note that, just like the repeater’s own OnItemLoad event, this listener’s OnMove event will fire for each row, within the context of each row, (E.g., it can access dataset values for the current row, get the current value of Item.index, etc.) So you can think of a listener having its own OnItemLoad event, but in the form of its OnMove event.

This repeater has two listeners. The first calculates the average, and the second writes the percentage to each row.

(If you Google “Axure repeater listener” you will find many examples on these forums.)

Live sample

File: create_benchmark.rp (61.1 KB)


Hey @josephxbrick, Thanks for the help on this one! It works perfectly! The only thing that I’m having trouble with is finding where the “average” variable is assigned its value to calculate the benchmark. I thought it was in the text outside of the repeater, but when I changed the name of that text, it didn’t change in the benchmark calculation. Do you think you could point this out for me? Thanks!


When you change the name of a widget that is referenced by code, it will still be referenced by the same code. (Internally, Axure doesn’t use the name of the widget for its code targeting, though you’ll notice that the name of the object is updated when you open the previously written code.)

The text on the “average” widget is updated by one of the “listeners” (hotspots) in the repeater. This graphic might help explain what is happening:

1 Like

Hi @josephxbrick , this helps! However, when I change the name of the “average” box, it doesn’t appear to reflect in the code itself. I’ve attached a file that changes the box for “average” to “Average_Calculation”, but if you check the repeater code/logic, it doesn’t update there in the benchmark listener. If I manually change it to “Average_Calculation” in the code, it provides just a string of text.

Am I doing something wrong? Thanks!

create_benchmark_edited.rp (70.4 KB)

Hi @josephxbrick I was actually able to come up with a workaround! Using the benchmark listener and the onLast condition, I just assigned the value of the average textbox to a variable and used that in the calculation. Worked like a charm! Thanks for all of the help!

Hi lcardona! Glad I could help.