Hiding 0's from charts when data is not all 0's

Grafana 9.5.1
MariaDB

I have the following query.

Select
SUM(CASE WHEN handoff = ‘yes’ THEN 1 ELSE 0 END) AS ‘Yes’

, SUM(CASE WHEN handoff= ‘no’ THEN 1 ELSE 0 END) AS ‘No’

, SUM(CASE WHEN handoff= ‘n/a’ THEN 1 ELSE 0 END) AS ‘N/A’

, SUM(CASE WHEN handoff= ‘cr’ THEN 1 ELSE 0 END) AS ‘CR’

, SUM(CASE WHEN handoff= ‘user deferred’ THEN 1 ELSE 0 END) AS ‘User Deferred’

, SUM(CASE WHEN handoff IS NULL THEN 1 ELSE 0 END) AS ‘Blank’

, department
from table
group by department

The dataset is not all 0’s, however some of the bars have 0 values. I cannot stack the bars or the numbers become illegable by having zeros stacked ontop of the actual number.


Is there a way to do a value mapping to make any 0 = ‘’ (thats a blank space), or just not show any value that is 0?

I attempted to do a "having ‘yes’ > 0 or ‘no’ >0 ect ect and it broke the query.

I have seen multiple requests to make this an option, but I have not found any indication that its been added to the product. We cannot install plugin’s so the solution has to be from grafana proper.

are those the only handoff types? if so what you had should have worked with

where [Yes] > 0

But it will have a bad effect on all other rows.

So, in the FROM selection, I should not name the table, but the outcomes for the above sums?

Do I have to list out every combination of (handoffName as handoff, ‘departmentName’ department)?

no that is just me emulating your table as I do not have direct access to yours :wink:

I am not having any luck getting this work work properly, even Chatgpt isn’t able to crack it.

Is there any posibility of just moving the numbers to be inside their respective bars?

you mean not stack them?

LOL that is an option, but then the amount of bars is just too many, its still showing all the 0 values.


In this instance I know I can either make the panel taller, or increase the distance between bars, but that then makes the panel not totally appear on the screen, and won’t pass QC.

I’m having the oppsite issue with my heatmap table, I need to to always show Sun-Sat yet it hides the rows when there is a 0 value >_>.

image

well it is doing what you give it in the data but then when you try to eliminate them it will hide important data as well because it is now pivoted. the issue is your query

What would the final data in csv format look like…exactly my point :laughing:

I just wanted to come back and share my solution for hiding zeros in the bar charts…

Instead of THEN 1 ELSE 0, I changed it to THEN 1 ELSE NULL

1 Like