Dashboard Transformation: Add Field from calculation: "+" = string concatenation instead addition

Grafana version 9.2.3, CentOS 7.9, Chrome Browser

  • What are you trying to achieve?
    checking out transforms. Using “table”. Trying transform “Add Field from calculation”, Mode: “Binary Operation”, add Value (e.g. 12) to field “status_code” (e.g. 200)

  • How are you trying to achieve it?
    see pics

  • What happened?
    Instead of calculating numbers: string concatenation happens. Same with adding other number-Field-content instead of “fixed number”. All other Operations like “-”, “*”, “/” are working fine (result is math-calculated)
    Example: status_code=“200”, Binary operator=“+”, Fixed Value to add=“12”, Result-field=“20012”

With another field “value”=“200” the addition is fine! My assumption: Fields have different datatypes: “status_code”=String, “value”=Number

  • What did you expect to happen?
    e.g. Field content=200, adding 12 should create new field with content “212”

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    → No

  • Did you follow any online instructions? If so, what is the URL? No

I bet your status_code is a string (which looks like a number).
Try to add transformation Convert field type before this one and force status_code to be a numeric first.

1 Like

What data type is status_code in your datasource? And what data source is it?

That’s what I have assumed. But transform should operate consistently. “-” gives the math result while “+” returns string result … that should be corrected!

If it’s INTENDED to operate with strings then “200” - “12” should result in “200” because there is no string “12” in “200” … :wink: that’s what I would expect

Then talk to Javascript developers. Test in your browser console how it is implemented: