How to Create a Stacked Bar Chart with Data Across Multiple Rows in Grafana?

Hi everyone,

I’m working with data in the following table format:

Time, UserName, Value
2024-10-22T00:00:00Z, User1, 10
2024-10-22T00:00:00Z, User2, 15
2024-10-22T00:00:00Z, User3, 5
2024-10-23T00:00:00Z, User1, 20
2024-10-23T00:00:00Z, User2, 25

I want to create a stacked bar chart in Grafana where:

  • Each bar corresponds to a single Time.
  • The Value for each UserName is stacked on the same bar for that time.

I managed to calculate the total values for each Time using a group by, but in this case, I lose the information about individual users.

For example, with a group by:

  • 2024-10-22T00:00:00Z results in a total of 30 (10 + 15 + 5).
  • 2024-10-23T00:00:00Z results in a total of 45 (20 + 25).

However, I want the stacked bars to preserve the breakdown by UserName so that each user’s value is visible as a separate segment on the same bar.

I’m using the Infinity datasource with the data in a CSV format.

Could someone guide me on how to:

  1. Transform the data if necessary?
  2. Configure the panel to display the stacked bars with segments for each UserName?

Thank you in advance for your help!

1 Like

thanks