Forum Discussion

PowerAutomater's avatar
1 year ago
Solved

How to plot multiple measures on a line graph?

I have event data containing dates and durations and also another field which categorises these events, for example:

Event NameDateDuration (hrs)Category
Event 11/1/20251Type 1
Event 21/1/20250.5Type 2
Event 12/1/20251Type 1
Event 33/1/20253Type 3
Event 44/1/20252Type 3
Event 25/1/20250.5Type 2
Event 52/1/20254Type 2

(apologies about the formatting it keeps getting stripped out)


I have plotted these on a line chart with date on the X axis, duration on the Y axis and the categories in the legend. This is fine however what I need is to combine Type 1 and Type 2 into a single line, so that the chart is comparing Type 1&2 combined vs Type 3.

I created the following measue to combine Types 1&2:

New Measure =

CALCULATE(SUM(Query1[Event Duration]),Query1[Category] = "Type 1")
+
(CALCULATE(SUM(Query1[Event Duration]),Query1[Category] = "Type 2"))

I think this is right, but the problem is that PowerBI won't let me drag this measure into the Y axis field or even the secondary Y axis. I've tried turning the Type 3 into a measure as well but I'm still not able to drag both into the line chart fields.

How can I do this to have the 2 lines in the chart?
  • Hi,

    Write this calculated column formula in your Data table

    Category new = if(or(Data[Category]="Type 1",Data[Category]="Type 2"),"Type 1 & 2",Data[Category])

    Use this Category new column for building your viz.

    Hope this helps.

5 Replies

  • Hi,

    Write this calculated column formula in your Data table

    Category new = if(or(Data[Category]="Type 1",Data[Category]="Type 2"),"Type 1 & 2",Data[Category])

    Use this Category new column for building your viz.

    Hope this helps.

    • PowerAutomater's avatar
      PowerAutomater
      Helper IV

      This worked, and then I used the new column in the legend instead of the existing category. Thank you

  • Create a group over the Category field. Group 1 and 2 together and all others by themselves.  Use the group as the legend.

    • PowerAutomater's avatar
      PowerAutomater
      Helper IV

      I'd like to try this but not quite sure what you mean. Are you able to provide a step by step please?