Forum Discussion

PrakashPalle's avatar
PrakashPalle
Icon for Helper II rankHelper II
10 months ago
Solved

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: 

 

9 Replies

  • 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.

  • 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] per yr_mon2 column 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 use Actual Sparkline as the sparkline field while keeping only one “Sum of Actual” column in your matrix.
    Remove yr_mon2 from 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_mon2 to the sparkline setup instead of Columns

    1. Keep only your measure (Sum of Actual) in Values.

    2. Remove yr_mon2 from Columns.

    3. Add a sparkline to Sum of Actual → set the X-axis field to yr_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's avatar
    v-echaithra
    Icon for Community Support rankCommunity 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.