Enhanced calculation Add field from calculation - Total of the column divided by single row

  • What Grafana version and what operating system are you using?
    v9.3.2

  • What are you trying to achieve?
    I would like to add a new calculated field. The total sum of a specific column divided by a single row.

  • How are you trying to achieve it?
    Transformation → Add calculated field

  • What happened?
    I can only choose predefined binary operation. Value of a row devided by value of another row. Can’t choose the total of the column divided by single value in a row.

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?
    In this picture you can see three colums with integer values. I added the total sum in the footer.
    I would like to generate a new column (Percentage) Total of the column divided by the single value of the column multipled with 100 → Percentage of the Value.

I only can choose these operations: (Only an choose the column single value, not the total)

Any idea?

@johanneseichermuelle

I am not sure it’s possible and do not have much time to play around with it. Maybe use 2 transform operations: Reduce row to Total, then Binary operation…Something like this:

Thank you for your, response. I tried a little bit around, but that doesn’t work.
Add field from calculation Mode “reduce row”, calculation total, shows me the total of all integer values in the row. If I choose one field name, it shows only the single value.

What is your datasource? If it’s InfluxDB, I know this can be easily done using Flux.

My datasource is a ms sql database.

Can you share the SQL query that generated this?
image

Yes i can calculte it in my sql query. Like:
SELECT
Kanbananzahl,
Stückzahl,
Reseriert,
Kanbananzahl / (SELECT SUM(Kanbananzahl) FROM Tabelle1) * 100 as PercentageKanban
FROM Tabelle1

That can be a solution, but there is no extended calculation in grafana?

What do you mean by extended calculation. You better off letting grafana do what it does best: visualize

I would recommend doing any other calculations in sql server itself

1 Like