Math with numeric values derived from a dropdown field I had a dropdown field with a handle of hLevel, with only numeric values in it, anticipating that I could do math with the values in my template. But it seems I can't.

{% set dif = subhead.hLevel - subhead.next.hLevel %}

…returns an error message ending in:


  “could not be converted to int”


I found a thread convinced that number_format “converts a string to a number”, so I tried that:

{% set dif = subhead.hLevel|number_format - subhead.next.hLevel|number_format %}

…but that doesn't work either. The error message changes to:


  “could not be converted to double”


Which doesn't surprise me as I did think that number_format is for float to formatted string conversion, not the other way round as well.  ¯\_(ツ)_/¯

When I change the field format to number everything works fine, but…

It would be good if there is an option to have dropdown field values be parsed as numbers, because from a UX perspective I would prefer that the field is a dropdown.

Or is there some workaround I've missed?
Have you tried subhead.hLevel.value?