Subtracting values of two tiles and show in 3rd tile

Hi Folks!

I am using Grafana to display Total, Active and Inactive devices. I could calculate the Total Devices and Active devices and display them in individual single stat tile. Now I want a third tile that will show the Inactive Devices (by subtracting Total and Active devices).

My dashboard looks something like this.

Can you please help me out with a suitable way to do this in Grafana?

Thanks in advance.

Subhadeep Datta

Hi @sahebdatta1996,

I can think of several possible solutions, but I suppose it depends on what your data and queries look like. What is your datasource? are total device and active device each the result of separate queries?

Maybe take some screenshots of the query editor with your data viewed with the table visualization?

Hi @mattabrams,

Thanks for the response. Sorry, I should have mentioned it already. The data source is InfluxDB. Here’s what the queries look like:

A brief explanation: Both the queries query from different databases. B is the total number of available devices which is obtained from a Config table. A is the total count of Voltage data received in a span of 30s. This gives me the devices which are active. Now I need to show the number of inactive devices.

Additionally, I also need to show the device address (IP Address) of the Inactive devices. The idea is I know the IP address of the devices which are active and the total devices available. So somehow if I could compare and list the devices that are not active.

@mattabrams also please take a look at this post: Referencing value from one query to another


I would try using a transformation like Add Field from Calculation.

You could add a third field called Inactive, and set its value as the difference between Total and Active

1 Like

Hi @mattabrams,

Thanks for the response. I add some SS which will explain the situation.

As you see, query A is not time-based and is constant. I suppose for this very reason I am not getting the expected result.


Can you show me the data results from your two queries in table format? I must be missing something here…

Hi @mattabrams,

Really appreciate your support regarding this topic right from the start. Maybe I am reframing my objective a bit. I think I would like to have the tables separated of the active and deactive devices. By separating them, I can easily count the number of devices. This is the goal that I want to achieve. Can you please take a look to this post, please. Compare data b/w 2 tables using kapacitor (tick script) - Welcome & Getting Started - InfluxData Community
This is from one of my colleagues. This is exactly how I would like to build up the tables and than the calculation would be much easier.