Skip to main content

Can I use variables in formulas


Forum|alt.badge.img+3

I want to put the result of another field in place of [#] in the formula: DATEADD([date], [#], ‘units’)
I’ve tried enclosing the field name in [] {} () but nothing seems to work.

Am I missing something?

Forum|alt.badge.img+18
  • Inspiring
  • September 22, 2016

Usually you don’t need 'm (only use when there are {spaces your field name}). And when you use the formula editor it will fix that for you. Simply pick the field from below and narrow it down by typing the first character(s) from the name.

Also, it shows examples in the editor. :slightly_smiling_face:


Forum|alt.badge.img+3
  • Known Participant
  • September 22, 2016
Tuur wrote:

Usually you don’t need 'm (only use when there are {spaces your field name}). And when you use the formula editor it will fix that for you. Simply pick the field from below and narrow it down by typing the first character(s) from the name.

Also, it shows examples in the editor. :slightly_smiling_face:


Thanks Tuur, I probably should have been more complete in my description: As well as trying [], {} and (), I tried it with just the field name, but to no avail. The only time this formula worked was if I inserted a specific number for [#]

I’ve had success using variables in other formula, just not this one:
DATEADD([date], [#], ‘units’)


Forum|alt.badge.img+18
  • Inspiring
  • September 22, 2016
James_Samuel wrote:

Thanks Tuur, I probably should have been more complete in my description: As well as trying [], {} and (), I tried it with just the field name, but to no avail. The only time this formula worked was if I inserted a specific number for [#]

I’ve had success using variables in other formula, just not this one:
DATEADD([date], [#], ‘units’)


Ah. In that case it could be a specific date related conversion thingy. :slightly_smiling_face:

I’ll have a closer look at it later…


Forum|alt.badge.img+18
  • Inspiring
  • September 22, 2016
James_Samuel wrote:

Thanks Tuur, I probably should have been more complete in my description: As well as trying [], {} and (), I tried it with just the field name, but to no avail. The only time this formula worked was if I inserted a specific number for [#]

I’ve had success using variables in other formula, just not this one:
DATEADD([date], [#], ‘units’)


No probs here when I use…

DATEADD(Datefield, Numberfield, 'day')

Forum|alt.badge.img+3
  • Known Participant
  • September 22, 2016
Tuur wrote:

No probs here when I use…

DATEADD(Datefield, Numberfield, 'day')

Thanks for testing this Tuur - I also keep trying but this formula field only returns the same date as the [Datefield] with an additional (unwanted) time stamp of 12:00am.

https://airtable.com/shrX2oVgmvKcDyXfE
The formula in NextDateDue field reads: DATEADD(JobDate, Frequency, ‘day’)

:slightly_smiling_face: It’s going to be fun when we get to the bottom of this one :slightly_smiling_face:


Forum|alt.badge.img+18
  • Inspiring
  • September 22, 2016
James_Samuel wrote:

Thanks for testing this Tuur - I also keep trying but this formula field only returns the same date as the [Datefield] with an additional (unwanted) time stamp of 12:00am.

https://airtable.com/shrX2oVgmvKcDyXfE
The formula in NextDateDue field reads: DATEADD(JobDate, Frequency, ‘day’)

:slightly_smiling_face: It’s going to be fun when we get to the bottom of this one :slightly_smiling_face:


What happens when you change the format of {frequency} to drop the decimal point & zero?


Forum|alt.badge.img+18
  • Inspiring
  • September 22, 2016
James_Samuel wrote:

Thanks for testing this Tuur - I also keep trying but this formula field only returns the same date as the [Datefield] with an additional (unwanted) time stamp of 12:00am.

https://airtable.com/shrX2oVgmvKcDyXfE
The formula in NextDateDue field reads: DATEADD(JobDate, Frequency, ‘day’)

:slightly_smiling_face: It’s going to be fun when we get to the bottom of this one :slightly_smiling_face:


Oh. Now I see that the field is not a number field. As lookups are handled differently (as arrays) that could be the problem. :slight_frown:


Forum|alt.badge.img+3
  • Known Participant
  • September 22, 2016
Tuur wrote:

What happens when you change the format of {frequency} to drop the decimal point & zero?


Yes, apparently the DATEADD formula will not accept a number from a Lookup or a Formula ONLY a Number field :frowning:

This is unfortunate, as the number I am wanting to reference is from another table. The only way around this is likely to involve copying from the lookup and pasting into a number field for every new record.


Forum|alt.badge.img+18
  • Inspiring
  • September 22, 2016
James_Samuel wrote:

Yes, apparently the DATEADD formula will not accept a number from a Lookup or a Formula ONLY a Number field :frowning:

This is unfortunate, as the number I am wanting to reference is from another table. The only way around this is likely to involve copying from the lookup and pasting into a number field for every new record.


And what happens when you use the {freq} field?


Forum|alt.badge.img+3
  • Known Participant
  • September 22, 2016
Tuur wrote:

And what happens when you use the {freq} field?


That field works, as long as it’s a number field only - as I edited in the above reply, it seems copying from the lookup and pasting into a number field for every new record is the only solution.

Any idea for how to remove the extra time format in the result of this DATEADD formula?


Forum|alt.badge.img+18
  • Inspiring
  • September 22, 2016

Yup. Simply use an extra DATETIME_FORMAT. :slightly_smiling_face:

Also, I came up with a possible workaround. Please try a rollup field instead of the lookup.


Forum|alt.badge.img+3
  • Known Participant
  • September 22, 2016
Tuur wrote:

Yup. Simply use an extra DATETIME_FORMAT. :slightly_smiling_face:

Also, I came up with a possible workaround. Please try a rollup field instead of the lookup.


Awesome - Rollup and DATETIME_FORMAT all works beautifully now - thanks a bunch for that workaround! :slightly_smiling_face:

(from down under in New Zealand)


Forum|alt.badge.img+18
  • Inspiring
  • September 22, 2016
James_Samuel wrote:

Awesome - Rollup and DATETIME_FORMAT all works beautifully now - thanks a bunch for that workaround! :slightly_smiling_face:

(from down under in New Zealand)


My pleasure. No worries! :winking_face:


Reply