# Conditional canonical transform to a ExactDimension field

#1

I want to create a canonical transform expression like this:

`consumption: ~ expression "(exists(consumptionUOM)&&exists(consumption))? ({unit:{id:consumptionUOM},value:consumption}) : null"`

consumption is an ExactDimension field on the target type. I only want to transform to it if consumptionUOM and consumption are both defined in the canonical. However this expression doesn’t work. consumption is never transformed.

What’s the correct way to write this transformation?

#2

That expression is expected to work. You should log a ticket for it

Alternatively, see `dimensionCreator` function that you should use for this