Dashboards & Visualizations

Legends in bar chart

erkin
Engager

Hi, Im a novice to Splunk and i have a question regarding visualization.

I have my query like this:

 

 

|...myBaseQuery
| chart c as "Count" by category

 

 

This results in me only having one legend in my visualization, "Count". I was wondering if there's any way to get the all the values as a legend on the right (see image) ?


I realized this is possible when i also use the retailUnit in the chart command:

 

 

|...myBaseQuery
| chart c as "Count" by retailUnit category

 

 


Then I get one label for each category (see image), but i want to achieve this without sorting on retailUnit.

Is this possible?

Skärmavbild 2024-03-18 kl. 10.18.55.pngSkärmavbild 2024-03-18 kl. 10.12.47.png

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Do you mean something like this

| eval static="Category"
| chart count by static category

View solution in original post

0 Karma

erkin
Engager

Yes! Exactly what I need, thank you.

Now the only issue I'm having is that I'm no longer available to sort the bar chart in descending order. Earlier I used to do | sort -count, but that doesn't seem to work using static

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Yes, chart will sort the columns by name. In order to get around this, you need to use transpose

| eval static="Category"
| chart count by static category
| transpose header_field=static column_name=category
| sort - Category
| transpose header_field=category column_name=static

ITWhisperer
SplunkTrust
SplunkTrust

Do you mean something like this

| eval static="Category"
| chart count by static category
0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...