is there a way to display the sum of 3 rows in a table?
Icebox
Member Posts: 1,485
Hello I want to add 3 rows in a table and use display text to show the value ? is there a way to do it ?
thanks
Comments
Are the three rows in the same column? If so you can use the column sum value function in the expression editor.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Can you provide a few more details? There's a big difference between adding these...
1
2
3
or these...
1 2 3
1 2 3
1 2 3
or these...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang i have a table that has 99 rows and 1 column , for stars collected , each row is for an individual star , each level has 3 stars , so i want to display how many stars collected on each level , i want to display text the sum of 3 rows and replicate the sum , so level 1 will be row 1 2 3 , level 2 will be row 3 4 5 , level 3 row 6 7 8 , i dont know if theres an easier way to do it ,
@Lost_Oasis_Games i just noticed ill give it a try thanks
Are you saying that your stars are stored such that this:
1 *
2 *
3
Would mean the player has two stars on level 1?
And this:
4 *
5
6
Would mean the player has one star on level 2?
If so, I'd suggest having a single row for each level. Change the value of the column to 1, 2, or 3 whenever the number of stars for that level changes.
Either way, you'll still be summing the columns...
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
thanks for the help ill just cancel it for now i cant get it right
Okay, well if it helps here's a demo of the function.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang thank you so much this is close to what i was looking for ! so this sums it all up , is there a way to only add the first 3 rows ? if there isnt i guess ill do as you said ill change it to column i should have done that to begin with , thanks again really appreciate it
Personally, I would restructure the table. It's going to save you time and headache in the future. But to answer your question, yes, you can add the first 3 rows.
The tableColSum() function takes the starting and ending row numbers as arguments. I just happened to choose 1 and tableRowCount() as values for those:
tableColSum( game.|T| Stars ,1,1,tableRowCount( game.|T| Stars ))
but you could just as easily choose 1 and 3:
tableColSum( game.|T| Stars ,1,1,3)
By the way, the second argument is the column number which is why I have it set to 1. But if you wanted to add the 4th through 6th rows of the 12th column of a table, it would look like this:
tableColSum( game.|T| Stars ,12,4,6)
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User