Are you using our SaaS platform (Baserow.io) or self-hosting Baserow?
SaaS
What are the exact steps to reproduce this issue?
I need to calculate expected consumption of product per year. The number is calculated by multiplying annual value with share of year left. But the formula returns the numbers as a list. That means that when I try to make the rollup in another table, it returns an error and I am unable to make the rollup work. I would appreciate any help with this very annoying issue
Attach screenshots, videos, or logs that demonstrate the issue.
Hey @AnnaRiis, try taking your current formula and wrapping the value in tonumber()
If it doesn’t work, can you please share your formula here?
My formula is this if(
year(field(‘igangsat’)) < tonumber(join(field(‘år’), ‘’)),
field(‘årligt forbrug (mwh)’),
if(
year(field(‘igangsat’)) = tonumber(join(field(‘år’), ‘’)),
(date_diff(‘day’, field(‘igangsat’), todate(concat(join(field(‘år’), ‘’), ‘-12-31’), ‘YYYY-MM-DD’)) + 1) / 365 * field(‘årligt forbrug (mwh)’),
0
)
)
tonumber returns an error Error with formula: argument number 1 given to function tonumber was of type number but the only usable type for this argument is text.
But I have the same issue throughout the tables - Another fomula that doesnt return a number but a grey left aligned number (list) is this if(totext(field(‘solpark’)) = ‘Vandel’, sum(field(‘forventet forbrug i året’)), 0)
I see, rollup fields don’t work with arrays. Which rollup function are you trying to use — SUM or AVG maybe?
I am trying to use the sum function. But everytime something is calculated it turns numbers into a list - and the tonumber () doesnt work
You can try to use a formula field instead of a rollup field, and wrap your formula with the SUM function.
I tried that already - same error (because I need to use a filter I suppose). Is there no way I can turn a list into numbers?
Try this formula:
if(
year(field('igangsat')) < field('år'),
field('årligt forbrug (mwh)'),
if(
year(field('igangsat')) = field('år'),
(date_diff('day', field('igangsat'), todate(concat(totext(field('år')),'-12-31'), 'YYYY-MM-DD')) + 1) / 365 * field('årligt forbrug (mwh)'),
0
)
)
Thank you for looking into it - returns this error “
Error with formula: argument number 2 given to operator < was of type text but the only usable type for this argument is number.
Best Anna
Hey @AnnaRiis, it looks like our table setups are different. I tried to recreate your database, but I’m guessing some fields are different types. That’s why you’re seeing the error while the formula works for me.
Did you try to fix the formula with our AI assistant, Kuma?