Forum Discussion
Sparkline with Legend Present
Hi All, I’m trying to create a sparkline in a matrix visual that already has a legend. When I add a sparkline for the metric, it creates an extra column for each year-month instead of a single sparkline column. I’d like to have just one column for the sparkline. Could you please advise how to achieve this?
Actual:
Expected:
could you share your pbix-file?
9 Replies
- Ahmedx
Super User
- PrakashPalle
Helper II
- Ahmedx
Super User
You still need to change the DATA Category
- rohit1991
Super User
Hi PrakashPalle
This happens because Power BI sparklines depend on how your matrix is grouped. When your matrix already has a legend or separate fields like Year and Month in the columns, Power BI treats each of those combinations as a unique series. That’s why it ends up drawing multiple sparkline columns instead of just one. To get a single sparkline, try removing the legend or move it to the rows section so that all data rolls up together. Another good approach is to create a combined “Year-Month” column in your data model and use that for the sparkline’s axis , this helps Power BI recognize it as one continuous timeline. You can also make sure that your measure (like Actual or Sales) is used consistently without being split by multiple fields. Once you simplify the column grouping to one field, the matrix will automatically show a single, clean sparkline column per metric. It’s just how Power BI handles grouping logic internally.
- johnbasha33
Super User
Hi PrakashPalle
In Power BI, the behavior you’re seeing happens because the sparkline feature in a matrix is tied to the column hierarchy—each field in Columns (like
yr_mon2) generates its own sparkline column.
If you already have a legend or multiple measures, Power BI treats every combination of measure × column field as a separate sparkline slot.To show only one sparkline column per metric, you have two solid options:
Option 1 – Create a single “Month” trend measure for sparklines
Instead of plotting
[Actual]peryr_mon2column directly, create one trend measure that summarizes across the months in scope.
Actual Sparkline :=
VAR TrendTable =
ADDCOLUMNS (
VALUES ( 'DateTable'[yr_mon2] ),
"@Actual", [Actual]
)
RETURN
SUMMARIZE ( TrendTable, 'DateTable'[yr_mon2], "@Actual", [Actual] )
Then useActual Sparklineas the sparkline field while keeping only one “Sum of Actual” column in your matrix.
Removeyr_mon2from the Columns well so you don’t create repeated groups—Power BI will still draw the line by month behind the scenes.Option 2 – Move
yr_mon2to the sparkline setup instead of Columns-
Keep only your measure (
Sum of Actual) in Values. -
Remove
yr_mon2from Columns. -
Add a sparkline to
Sum of Actual→ set the X-axis field toyr_mon2.
Now the matrix shows one “Sum of Actual” column and one sparkline column summarizing the trend over all months, instead of one sparkline per month.
Option 3 – If you need a legend
When you also have a legend or multiple series (e.g., “Actual vs Plan”), pivot the legend to Values and use only one date field (yr_mon2) in the sparkline X-axis.
Power BI currently doesn’t support multi-series sparklines in a single cell, so the legend has to stay out of Columns.Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
-
- v-echaithra
Community Support
Hi PrakashPalle ,
If possible, could you please provide more details about your data?How to provide sample data in the Power BI Forum
You can refer the following link to upload the file to the community.
How to upload PBI in CommunityThank you.
- v-echaithra
Community Support
Hi PrakashPalle ,
If the issue still persists, we kindly request you to share the sample data in a workable format such as text, an Excel file, or a PBIX file with sample data instead of screenshots. Additionally, please include the expected output. This will enable us to assist you more effectively.
Best regards.