Formatting based on Formular based on year, month, week, day

Hello all,

how can I format my colum chart based on this formula?

CASE 
WHEN '<%= unit %>' IN( 'YEAR') THEN '%Y'
WHEN '<%= unit %>' IN( 'MONTH') THEN '%Y-%m'
WHEN '<%= unit %>' IN( 'WEEK') THEN '%Y-%m'
WHEN '<%= unit %>' IN( 'DAY') THEN '%Y-%m-%d'
END

The formula doesn´t work in the format space.


Thank you in advance.