Problem setting variables to zero

I have several instances of three main repeater tables. (Yes the data is synthetic)
I use a separate set of variables for each of the tables’ calculations, which I set to zero on certain events - like using droplists to select the different tables.
But the math gets inconsistent, and I have only gotten close to a perfect solution by hacking it with an automated change droplist option->wait->change back, in order to have the first instance of the repeater set text sums based on zeroed variables. But it is still a little off with the math.

This prototype has gotten quite complex for someone not super skilled with the most advanced parts of Axure so if anyone with a more suited brain than mine would lend a hand I would be super happy.

Hey @sirtommy, I’ve checked your file, and it appears that some of the variables that you use for different repeaters coincide, and that’s why you see this strange math in the console tool. For example, SumAdmin, SumOrdinar, SumEndring , and SumTotal variables are being used in the repeaters “Ansatte 1 23” and “Factura 1 2023”; SumOrdinar and SumEndring variables are used to store the sum value in the repeater “Hendelser1 23” and “Factura 1 2023” as well. I will explain how these values in your console are counted on the example of the variable “SumAdmin” from your file. Open our console tool and reload the page. On the top of your page, you see the list of variables, and you see that the SumAdmin variable there “12446”. To see why this variable got to this value, scroll the console to the bottom. First, you see that you set this variable to “0” under the “Page Loaded” event. Then, for the “Item loaded” event of the repeater “Repeater faktura 1 2023 (Repeater)”, you sum up the values in the “Item.Admin” column and the current value of you variable becomes 0+358245+2000000+369124+375125=3102494. After this, you use the same variable SumAdmin in the “Item Loaded” event for the “Repeater Ansatte 1 23 (Repeater)”, where you set its value to zero first, and then you summarize the column “Item.Admin” which is 12446–the final value of this variable that we see in the console. If you use different sets of variables to store sums of the columns for every repeater, you should be able to see the sum on these repeater columns in the console.

Aaah. I thought the same set could be used all over as long as they were set to zero here and there.

So does this mean that for my 3 tabs each containing 4 repeaters - I will need 12 sets of variables?

Hello again @Tanya_Axure - did I understand correctly when asking if I need 12 sets of variables because of my 12 different repeaters appearing in this prototype page?
I did read in the forum that Axure recommended no more than 27 global variables - so I am a little concerned because in my case I would end up with way more than that.

Hey @sirtommy, thanks for tagging me! I apologize that I overlooked your question earlier. Since you have several repeaters, you might want to store the sums of each column in different variables to avoid any confusion with math. We don’t have a limit for the number of global variables, but this “27 global variables” rule makes me very curious, so I will reach out to our product team and get back to you once I know more.

I recall the max limit for global variables being somewhat fuzzy, and somewhat variable (no pun intended) based on how long (char count) the total variable strings might be, available system resources, etc. You can have more than 27 global variables but reliability may be at risk, or if you have a lot of data stored in global variables, maybe 27 is too many, or maybe your prototype works on some devices and browsers, but not others, etc.

@sirtommy, How much data and how many global variables do you need to pass between pages? If you are using a global variable only for temporary or calculation purposes on the same page, it may well be worth using widget text values as a form of “page-local variable”. This could help with your “inconsistent math” issues as well, especially if you have multiple repeaters trying to use the same global variables for different calculations. For example, if you have a global variable named SumAdmin and don’t need to use it on other pages (or if it’s value is dynamic and can change on the page before navigating to another page) you could just use a rectangle widget with the same name and a Set Text Value action instead of Set Variable Value.

When I have complex or calc-heavy repeaters, input forms, pages, etc., I will make a “Data Panel” to house page-local variables and “sub-routine widgets”–a dynamic panel (or group) with a bunch of rectangle widgets used to store data values and/or functions. I keep it shown by default in the editor and assign a Loaded event to “Hide This” so it doesn’t show in the prototype/browser (which I find easier to use than hiding each widget on the canvas.) If I need to debug things, I’ll include a Page Key Up event with condition to test for a “god mode” key or combo, like Shift+Alt+V or something, that toggles visibility of my data panel. In your case, each of your repeaters could have its own data panel (which I often do as well–creating a dynamic panel from my repeater and then nesting another dynamic panel next to the repeater so they are all logically together.) Just be sure to name all your page-local variables uniquely.

Thanks I was starting to consider those local variables - it’s just that I didn’t know quite how, so thanks a lot for the tip.

Eventually I ended up using 35 or so global ones, and everything fortunately seems to be working fine :sweat_smile: