Column 2 Values Sum

I just started using this a few weeks ago and decided to try to make my own and I am stuck. I want to have students create a list of ingredients in column 1 and prices for those ingredients in column 2. I want to calculate the sum of the prices they enter. From endless searching, it looks like having the list populate in a graph is how I have to do this. So I did…

numberList("T"): grocery_input.columnNumericValues(2)

on the graph CL. But I can’t get it to populate numbers. And even if it was working, I don’t know how to sum the numbers and then reference that in a different note. Any help is greatly appreciated!

If you are going to populate the list of a, b, c, etc, I would think your expression in the calculator should be something more like L=[a,b,...] You can then use total(L) to sum together the elements in that list.

Instead of populating a list, you could just write a formula to sum the numbers together like T=a+b

Note that for either method you will need to define a and b (and all your other numbers) in the calculator component’s CL.

I added a note to display those defined values for a andb as well as the total calculated by adding the numbers together (no list) and the total using a list.

Hope this helps!

1 Like

This is perfect and will do exactly what I’m wanting. Thank you!

I have another question, if you might know the answer: Is it possible to do

numberList(P): grocery_input.columnNumericValues(2)

on the CL of graph1 and then on the graph and then L=[Q] in order to get it to calculate any and every number that gets added onto grocery_input?

You can, rather than defining numbers, a and b, define the numberList(L) and use @CL_Noob 's other graph value T_L for the total.

numberList(`L`): grocery_input.columnNumericValues(2)
1 Like

@MattSwymer I had never used the table.columnNumericValues before. Defining list L in the graph’s CL using the code @Daniel_Grubbs provided will ensure that list L is populated using all values entered into column 2 of that table. Then T_L=total(L) will sum together the elements of the list. Nothing he didn’t already say - just summarizing for my own learning here :slight_smile:

My copy of the activity is now updated to show how efficient that works without the need to define all of the variables, etc. It’s fun learning new stuff on here. Thanks for asking the follow-up!

2 Likes

I’m so glad you updated yours so I could see it because I was about to spend an hour trying to figure out how to do that.

I feel I’m learning the CL a bit, but still need a lot of work. The graph functionality… not so much. That’s why I appreciate y’all doing this so much!! I’ve learned more about this in the past 2 weeks than I ever thought I would.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.