Conditional value format

Hi,

I have an amount column which should be positive for some transaction types and negative for some other transactions. Can I put a conditional value format to do the same ?
Something like this -
{% if legacy_trans_type._value == ‘XFER’ %} -1 * {{ amount }} {% else %} {{ amount }} {% endif %} ;;

0 2 398
2 REPLIES 2

You can do that at several level (sql, html or table calculation on top of my mind) but it seems like creating a dimension that would look like this may be best:

dimension: transformed_amount {
   type: number
   sql:  CASE WHEN ${legacy_trans_type} = "XFER" THEN -${amount} ELSE ${amount} END;;
}

Using conditional formatting or HTML rendering can expose you to some issues on visualizations.

Thanks ! that worked.

Top Labels in this Space
Top Solution Authors