Rollup Field Doesn't Work

Hello, guys!

I’m new to Baserow and am coming from Airtable. I just wanted to replicate a base, but something is going wrong with the Rollup Field.

  1. I have an Ingredients table with the ingredient name, unit, and unit cost fields.
  2. I have a Pizza Recipe table linked to the Ingredients table from which I get each ingredient for every pizza. The unit and unit cost comes through lookup fields. I also have a quantity field and, at the end, a Formula field that calculates the total cost for every recipe ingredient.
  3. I have a Pizza Table linked to the Pizza Recipe Table, and here, I want to display the total cost of every pizza through a rollup field.

The error is the following:

Error with formula: argument number 1 given to function sum was of type array but the only usable type for this argument is a list of number, or duration values obtained from a lookup.

Can anyone help me, please? I don’t understand what is happening. In Airtable precisely the same flow does function very well.

Thank you!

image

image

image

Hi,

The reason you get the error is because linked fields and lookup fields in Baserow are always considered to be lists, even if they only contain one item. I tried to replicate your database structure.

  1. A table with Ingredients that have a field for the unit cost
  2. A table with Recipes. Each record in that table has an ingredient. There is only one ingredient for a record. So, I use the rollup function min() or max() to make sure that value is a number and not a list of items. You will notice that the grey background disappears and that the number is aligned to the right side of the field. This indicates that it is a number instead of a list of items

    I can now create a formula field that calculates the cost for that ingredient for a certain pizza based on the amount of the ingredient that is needed
  3. You can create a rollup field with the sum() function from the Pizzas table referring to that formula field

@frederikdc, thank you for your effort and explanation! I solved the problem :ok_hand: :handshake:

I’m having a similar problem. I’ve got a table that uses a lookup value to determine which rate to use in a given calculation. If I then try to rollup that calculation field to another table, it gives me the same error as above, namely:

Error with formula: argument number 1 given to function sum was of type array but the only usable type for this argument is a list of number, or duration values obtained from a lookup.

However, in the table where I’m performing the calculation, I can’t convert the result to a number (for use in the rollup) because it’s already a number…

Error with formula: argument number 1 given to function tonumber was of type number but the only usable type for this argument is text.

Specifics:

  1. Employees Table designates staff as Manager, Regular, or Sub. Managers get paid a different rate for Admin work than other staff.
  2. Payroll Calcs table rolls up all clinical, admin, and PTO hours from submitted timesheets per employee, per pay period, then multiplies each type of hours by the applicable rates. Admin rate is based on a lookup from the Employees table. It uses all this info to calculate gross pay for each employee.

  1. Pay Periods table rolls up total clinical pay and, ideally, admin and gross pay as well.
  2. The clinical rollup works great.
  3. An identical formula for the admin rollup produces the ‘argument has array but needs number’ error.
  4. Trying to convert the fields that makeup the Admin pay calculation to numbers gives me the error that they’re already numbers, even though the rollup formula doesn’t recognise them as such.

(I tried to upload multiple screenshots but it won’t let me since I’m new. Happy to add anything that might be helpful.)

Hello @olive2punk, sorry for the delay — we missed your message and I just noticed it today. Do you still need help with this? If so, could you please share the formula of the field that you’re using later for a rollup?

Hi –

Yes, absolutely. The field I’m trying to rollup uses the formula:

field(‘Rate-Admin’)*field(‘Admin Hrs’)

Where field(‘Admin Hrs’) is a rollup (sum) from another table and field(‘Rate-Admin’) is a formula, namely:

if(field(‘Mgr Admin’)=“Yes”,25,22)

I think the issue is that (field(‘Mgr Admin’) is a lookup field. Is this enough info?

Cheers,
Ollie

Hey @olive2punk,

I tried to rebuild your database.

Rate-Admin field:

Admin Hrs field:

Main formula:

And the Rollup for the main formula:

It’s working for me. Did I overlook something in the structure?

This all looks similar to mine. The one potential difference is the field(‘Mgr Admin’), which in my database is a lookup field (I can’t tell if it is in yours or not). In the screenshot I added to my initial post on this thread, you can see the Admin formulas have a grey highlight over the results, whereas the Clinical ones don’t have that highlight. My (very basic) understanding of this is that’ it’s due to the lookup field being considered an array?

Hey @olive2punk :wave:

Yes, that is correct.

In this case, we can use a formula field instead of the roll-up field. Which function you need to use — MAX?

Sorry, I’m not sure I understand the question – I don’t know what MAX means in this context :sweat_smile:

I’m trying to rollup the sum of the applicable values in the ‘main formula’ as you call it above.

(and thank you for all of your help!!)

Hey @olive2punk,

No worries. I meant which of these functions you want to use in the Rollup field:

Anyway, this simple formula should do the trick:

Which table does the “sum” function go in? If I try to put it where I want the rollup, I get the same error as I got with the rollup field, that it needs numbers, not an array.

Same thing happens if I use it with a separate lookup field, it says it can’t have an array argument, only numbers…

So I think I must have missed a step somewhere!

So it works with this formula:

field('Rate Admin') * field('Admin Hrs')

Rate Admin:

Admin Hrs:

Is it the same for you?

It still gives me the “can’t use array in sum” error… I”ve also tried adding a totext(field(‘Mgr Admin’)) and using that in the formula for field(‘Rate Admin’) and I get the same result.

In the ‘Rate Admin’, do you have this formula:

if(totext(field('Mgr Admin')) = "Yes", 25, 22)

And ‘Mgr Admin’: