Codex KPI Sparkline Card

KPI

A KPI card with an embedded sparkline trend — value, target, and trend in one tile.

Styles

2 stylings shipped — every one is a real render, in your theme.

Codex KPI Sparkline Card — Default
Default
Codex KPI Sparkline Card — Brand Blue
Brand Blue

Overview

One card. One value. One trend. Everything you need. Codex KPI Sparkline Card extends the standard KPI card with an embedded sparkline — giving you the current value, a target marker, and the trend over time in a single, compact visual. No need to place a separate line chart next to your card.

Ideal For

  • Monthly or weekly performance scorecards
  • Financial dashboards showing revenue vs budget with trend
  • Sales reporting — current month vs target with historical momentum
  • Any KPI where 'how did we get here' matters as much as 'where are we now'

Key Features

  • Headline value with large, readable typography
  • Target value with configurable variance display (absolute or percentage)
  • Embedded sparkline showing the full trend series — no extra visual needed
  • First/last axis label options to anchor the trend in time
  • Sparkline area fill, line colour, and end-dot all configurable
  • Sort order field well for correct time-based ordering
  • Hover tooltip on sparkline points showing category and value
  • Click sparkline points to cross-filter other visuals
Pro Tip

Wire the Sparkline Category to your date/period column and sort it by a numeric order measure. This ensures the trend renders chronologically regardless of how Power BI sorts text dates.

Help guide

What goes in each field

Field well Put in Required What it does
Value Measure Yes The headline number. A text measure works too, but the variance pill only shows for numbers.
Target Measure No Compared with Value to draw the variance pill and to pick the positive or negative colour.
Sparkline Values Measure No The trend line. It is evaluated once for each item in Sparkline Category.
Sparkline Category Column No The points along the trend, such as months. Without it the sparkline has only one point and is not drawn.
Sort Order Measure No A number that sets the order of the sparkline points, lowest first. Without it the points keep the order Power BI sends them in.

Value and Target are read from the first row the visual receives. Once Sparkline Category is bound, every field is evaluated per category, so Value and Target must return the same result on every row. The measures below show how.

Build the measures

The examples assume a Sales table with Date and Amount columns, related to a marked date table called 'Date' that has a Year Month column, plus a [Revenue Target] measure. Swap in your own names.

Value: revenue for the latest month with sales

Revenue Latest Month =
VAR LastSale = CALCULATE ( MAX ( Sales[Date] ), ALLSELECTED ( 'Date' ) )
RETURN
    CALCULATE (
        SUM ( Sales[Amount] ),
        REMOVEFILTERS ( 'Date' ),
        DATESBETWEEN ( 'Date'[Date], EOMONTH ( LastSale, -1 ) + 1, EOMONTH ( LastSale, 0 ) )
    )

ALLSELECTED ignores the month on each sparkline row but keeps your slicers, so every row returns the same latest-month figure.

Target: the target for that same month

Revenue Target Latest Month =
VAR LastSale = CALCULATE ( MAX ( Sales[Date] ), ALLSELECTED ( 'Date' ) )
RETURN
    CALCULATE (
        [Revenue Target],
        REMOVEFILTERS ( 'Date' ),
        DATESBETWEEN ( 'Date'[Date], EOMONTH ( LastSale, -1 ) + 1, EOMONTH ( LastSale, 0 ) )
    )

Sparkline Values: revenue for each point

Revenue =
SUM ( Sales[Amount] )

Sort Order: a number that runs in date order

Revenue Spark Sort =
VAR FirstDay = MIN ( 'Date'[Date] )
RETURN
    YEAR ( FirstDay ) * 100 + MONTH ( FirstDay )

This returns 202601, 202602 and so on, which sorts correctly across years.

Put it together

  1. Add the visual and drag Revenue Latest Month into Value and Revenue Target Latest Month into Target.
  2. Drag Revenue into Sparkline Values and 'Date'[Year Month] into Sparkline Category.
  3. Drag Revenue Spark Sort into Sort Order.
  4. In the Format pane, open Target and set Variance Display to Percentage, Absolute or Both.
  5. Open Value and pick Display Units and Decimal Places for the headline.

Tips

  • The variance is always Value minus Target, so above target shows the Positive Color. There is no setting to reverse it, so for costs compare a measure where higher is better, such as budget left.
  • Without a Target, the colour comes from the sparkline instead: the last point is compared with the first.
  • Sort Order must return a number. A date or text result is ignored and those points go to the end.
  • The sparkline is hidden when the visual is 100 pixels tall or less, and it needs at least two points with values.
  • An empty or blank Value shows the setup prompt instead of a card. Check the measure returns a result for the current filters.
From $1.49 / user / month · volume pricing from $29/mo

Billed through Microsoft AppSource


Category KPI
Tooltips
Cross-filtering
High Contrast