Line charts in Power BI: trends, series and axes

How to use a line chart in Power BI for trends over time, static and dynamic series, the secondary Y-axis, series labels, continuous or categorical axes, DAX for a moving average and a target, and what goes wrong.

Short answer: a line chart joins points in order, so it shows a trend: up, down, flat, seasonal, a break. Put time on the X-axis and a measure on the Y-axis. Several lines come either from several measures (static series) or from a field in Legend (dynamic series, one line per value), not both. Unlike columns, a line may use a Y-axis that does not start at zero, because the reader follows the shape, not the height.

The chart, part by part: What is a line chart? draws its parts and shows how to read one, its kinds and the mistakes to avoid.

Twelve months as columns show twelve separate amounts. As a line they show one movement: the dip in August, the climb before Christmas, the year that ended higher than it started.

The short video below shows when a line is the right chart, and what to do when too many lines turn it into spaghetti.

Nothing loads from YouTube until you press play. Then Google receives your IP address and may set its own storage. Narrated with an AI-generated voice. Privacy

When is a line the right chart?

When the X-axis has an order and the question is about change: daily visits, monthly revenue, weekly stock. Lines handle many points (365 days, 52 weeks) where columns would turn into slivers. With few categories and no order (regions, products), use columns or bars.

050100150200Goal 120JanFebMarAprMayJunJulAugSepOctNovDec
Monthly revenue against a goal of 120 (in thousands)

How do you show several lines?

Microsoft names the two ways:

  • Static series: add several measures to Y-axis, for example Units sold online and Units sold in store. Each is a line with a fixed name and its own format.
  • Dynamic series: add a field to Legend, for example Product. One line per product, and a new product gets a line by itself.

A chart with several measures on the Y-axis cannot also have a Legend field. When the measures have very different scales, drag the second one to Secondary Y-axis: it gets its own axis on the right.

  • Online
  • Store
0100200300400500Week 1Week 2Week 3Week 4Week 5Week 6
Two static series on one axis

With more than four or five lines, readers stop matching colours to the legend. Two fixes in Power BI: Series labels (Format visual) write each line's name at its end, with leader lines and an option to match the series colour; or Small multiples gives each product its own small chart with a shared axis.

Continuous or categorical axis?

In Format visual, X-axis, Type:

TypeHow points are placedUse for
Continuousin proportion to the value or date: a gap in the dates is a gap in the chartdates, numbers
Categoricalevenly, one slot per value, in sort ordernames, or when every period should get the same width

A continuous date axis also allows the Zoom slider and keeps missing days visible. Other X- and Y-axis options: Range (minimum and maximum), Logarithmic scale for data that spans several orders of magnitude, Invert range, and Title.

The Lines card sets colour, width, style (solid, dashed, dotted or a custom dash array) and Interpolation: Straight, Smooth (Monotone or Cardinal curves) or Step. Use Step for values that change at a moment and stay, like a price or a headcount.

What DAX makes a line chart useful?

The measure itself, then the lines that give it meaning. A three-month moving average smooths out noise:

Revenue = SUM ( Sales[Amount] )

Revenue 3M Avg =
AVERAGEX (
    DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH ),
    [Revenue]
)

That first version averages days. To average three monthly totals, iterate the months:

Revenue 3M Avg =
VAR Months =
    CALCULATETABLE (
        VALUES ( 'Date'[Year Month] ),
        DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH )
    )
RETURN
    AVERAGEX ( Months, [Revenue] )
MonthRevenueRevenue 3M Avg
Jan8080.0
Feb9587.5
Mar9088.3
Apr118101.0
May130112.7

Last year as a second line:

Revenue LY =
CALCULATE ( [Revenue], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )

A line that must not run into the future (dates with no sales yet) needs a stop:

Revenue to Date =
IF ( MAX ( 'Date'[Date] ) <= TODAY (), [Revenue] )

What goes wrong?

  • A line for categories without order. A line from "North" to "South" to "East" suggests a movement that does not exist. Use columns.
  • Zero where there was no data. A measure that returns 0 instead of blank drops the line to the floor for future months. Return blank (IF as above).
  • A zoomed axis without a clue. A line may start above zero, but say so: an axis from 95 to 105 makes a 2% move look like a crash.
  • Too many lines. Five or more crossing lines are a "spaghetti chart"; use series labels, highlight one line in colour and grey the rest, or small multiples.
  • Legend and several measures. Not allowed together: pick one way of making series.
  • Months as text on a continuous axis. Text is always categorical; use the date or a month start date for a real time axis.

Where can you check this?

Where do you start?

Put a date on a continuous X-axis, one measure on the Y-axis, and add a goal or last-year line only if it answers the question. Rolling 12 months in DAX covers moving averages in depth, and area charts are the line chart's filled cousins.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.