Variables in numbers?

Hi!

I've got a Social Studies assignment, you can read my awesome translation here 🙂

The assignment itself is rather easy, you don't have to do a function at all, but I'd like to automatically distribute the seats. The problem is that I'm used to programing syntax, and variables. Is there any way to use variables in Numbers? If you look at the result, you can see that I've tried to use cells as variables, but since it doesn't read from the upside down, but rather everything at the same time I doesn't work. It creates a loop, and I get errors. Or is there any other solution? How would you do it?

Am I thorough enough? Otherwise; ask away!


Thanks in advance,

Oskar Modig

MacBook Pro, Mac OS X (10.7.2)

Posted on Feb 2, 2012 8:29 AM

Reply
17 replies

Feb 2, 2012 12:14 PM in response to Punchlinern

If I totally understood how this works, here is a solution (click on the image to enlarge it)


User uploaded file


The formula in cell B2 =B$2/LOOKUP(SUM(H$2:H2),Table 2 :: $A,Table 2 :: $B)

Fill this to the rest of the cells under the vote counts


The formula in H3 =IF(B3=MAX($B3:$G3),1,0)

Fill this to the rest of the cells in that section of the table.


Table 2 is a lookup table for the divisors


The first formula counts how many seats the party has been given so far. It then looks up what the divisor should be and divides the party's votes by that divisor.


The second formula simply determines which comparison number is highest in the row and assigns them the seat. If two parties have the same winning comparison number, they would both get assigned a seat. This will result in extra seat asignments. I didn't try to solve that part of the problem.

Feb 2, 2012 10:32 AM in response to KOENIG Yvan

Oh, I'm sorry. I'm still rather new to iWork.com, and I didn't check the links. 😊
I'm new to Apple Support Communities, so this might be a very newbie-question, but is it possible to edit a post after getting a comment on it. I could have sworn that I saw a link for it under the Actions-meny, to the right.

The Assignment

The Result

And thank you for your quick answer, by the way 🙂

Feb 2, 2012 12:17 PM in response to Badunit

Badunit wrote too quick (I was dining).


Here is what I baught:

User uploaded file


In table "Calculations"

in cell B3, the formula is :

=ROUND(B2/1.4,2)

In cell B4, it's :

=IF(B3<>MAX($B3:$G3),B3,ROUND(B$2/3,2))

In cell B5, it's :

=IF(B4<>MAX($B4:$G4),B4,ROUND(B$2/5,2))

In cell B6, it's :

=IF(B5<>MAX($B5:$G5),B5,ROUND(B$2/3,2))

In cell B7, it's :

=IF(B6<>MAX($B6:$G6),B6,ROUND(B$2/7,2))


In table Sieges


In cell B3, the formula is :

=IF(1+MATCH(MAX(calculations :: $B3:$G3),calculations::$B3:$G3,0)=COLUMN(),1,"")

Fill down then Fill to the right.


The row 8 is a footer row.

In cell B8, the formula is :

=SUM(B)

Fill to the right.


Yvan KOENIG (VALLAURIS, France) jeudi 2 février 2012

iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2

My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k

Feb 2, 2012 12:31 PM in response to Badunit

It seems that you are right.

As I had no idea of the way the coef was defined I embedded it in the formulas missing the idea to store them in a table allowing us to work with a single formula.


Happily, we get the same final result 😉


Yvan KOENIG (VALLAURIS, France) jeudi 2 février 2012

iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2

My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k

Feb 9, 2012 2:59 AM in response to Punchlinern

Hello


Your formula was wrong.


In B3, insert :

=B$2/LOOKUP(SUM(J$2:J2),Table 2 :: $A,Table 2 :: $B)

Fill to right

Fill to bottom.


Yours was :

=B$2/LOOKUP(SUM(J$2:J3),Table 2 :: $A,Table 2 :: $B)

which failed because the cell J3 contain a formula referencing B3.


I changed a detail in the other set of formulas.

User uploaded file

In I3 I inserted :

=IF(B3=MAX($B3:$I3),1,"")

which give a table easier to read.


Something is bothering me.

To explain more easily, I inserted a column after the H one.

In the new cell I3, I inserted :

=LOOKUP(SUM(K$2:K2),Table 2 :: $A,Table 2 :: $B)

which is the subset of the main formula extracting the divider to apply.

User uploaded file

As you see, the scheme use the divider 1.4 twice. Is it normal ?


Yvan KOENIG (VALLAURIS, France) jeudi 9 février 2012

iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.3

My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k

Feb 9, 2012 4:11 AM in response to KOENIG Yvan

Hi!

The "divider extractor" does only look at party A right? Just to make sure I'm right.

In that case I think it is normal to divide by 1.4 twice (or all the times as in H). It doesn't matter how many times, does it? I mean, it doesn't affect the following numbers. It's the same as, for example in the A party, you divide by 5 five times.

Or am I wrong?

I think it's working now 🙂


I updated the document, look at the sheet "Finished".

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Variables in numbers?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.