Transformation of Table column values with conditionals

Hello all,

I have a table on my application which has data that was drawn from a Google Sheet API. I want to do some calculations on this column and generate a new column with the calculated values.

I want to return 60 if the column value is greater than 12, and return value *5 if it is not.

transformer

When I run this, all the values return as '[]'.

I would also like to note that I have tried to follow this forum (Apply transformer for each row in table - adding new column - #2 by chris-g) to no avail.

Any advice is greatly appreciated. Thank you!

1 Like

Can you post an example of your data that the table displays? This should be able to be done with {{currentRow.column > 12?’60’:currentRow.column*5 }} in a custom column value field

1 Like

Wow, that worked so easily. Thank you!! I am fairly new to javascript so I'm learning more and more each day.

Again, thanks for all your help!

Happy to help

1 Like

Hello again Scott,

I wanted to add an additional condition that returns 0 if ['Completed Tally'] is null. I attempted to chain the ternary operator as such:

{{ currentRow['Completed Tally'] > 12 ? '60': (currentRow['Completed Tally'] < 12) ? (currentRow['Completed Tally']*5): 0 }}

with no luck. Now, all values are returning as 0. Any advice? Thank you again in advance. I've learned a lot just working with the script you provided. :slight_smile:

try
{{currentRow.column > 12?’60’:currentRow.column*5 || currentRow['Completed Tally'] == null?0:'')}}
Though I am not sure if you want to set 0 if null and nothing if not - also not sure if you wan't this conditional to be added to the other OR using it as an additional rule....

Unfortunately, that did not work. I also tried the following, which also returned all 0s.

{{ currentRow['Completed Tally'] > 12?'60':(currentRow['Completed Tally'] < 12?currentRow['Completed Tally']*5:0) }}

Just to clarify, I only want one of three outcomes. If the ['Completed Tally'] value is greater than 12, then 60, if it is less than 12, then the val*5, if it is null, then 0.

I realized that you want to show this in the Column itself - if so:
{{self == ""?0:self>12?'60':self*5}}

if you want to apply this logic into another column and show the original column data then in the other column, simply use the same code, but replace self with currentRow