3 Replies Latest reply: Aug 30, 2013 5:20 AM by Wayne Contello
j-den Level 1 Level 1 (0 points)

It would be great to obtain some help to find the formula to obtain a code to implement the following procedure in numbers, iWork. Basically, I want to compare a cell (lets call the cell "a1") with a range of cells (abbreviated with "ci" where i stands for a range of numbers, e.g.1 to 10 so that we obtain the cell c1, c2 etc). If a1=ci, then I would like numbers to add add the respective values of bi (where b is a different column but the same row "i") and return the value of the sum. I hope my description makes sense.

 

abc:=proc(a1,c,b) #where c=column and a1=cell, b=column

q:=0
for i from 1 to 10 do #range 1 to 10 for simplification, best would be to add variables to that too

if ci=a1 then

q:=(q+bi);
end if;
end do;

return(q);

end proc;

 

Any help would be very much appreciated!


Numbers
  • 1. Re: Procedure
    Wayne Contello Level 6 Level 6 (13,620 points)

    there is a function called sumif() that will conditaionally sum a cell in a column if the value in another column meets a condition.

     

    Screen Shot 2013-08-30 at 6.49.52 AM.png

     

    In this example A1 if the value to test for.  Column B is what is conditionally summed, and column C is what is compared to A1

     

    A4=SUMIF(C, A1, B)

     

    column C contains the test values

    A1 contains the condition

    column B contains the sum values when the valus in the same row matches the value in A1

     

     

    There is a function reference builting that is pretty helpful.  You can open this vy selecting the menu item "View > Show Function Browser"

  • 2. Re: Procedure
    j-den Level 1 Level 1 (0 points)

    Thanks this helped me a lot! Solved the problem :-)

  • 3. Re: Procedure
    Wayne Contello Level 6 Level 6 (13,620 points)

    Greaty.  There are some super helpful people on these forums so post back with other questions.

     

    Best regards,

    Wayne