Forum Discussion
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 Name | Date | Duration (hrs) | Category |
| Event 1 | 1/1/2025 | 1 | Type 1 |
| Event 2 | 1/1/2025 | 0.5 | Type 2 |
| Event 1 | 2/1/2025 | 1 | Type 1 |
| Event 3 | 3/1/2025 | 3 | Type 3 |
| Event 4 | 4/1/2025 | 2 | Type 3 |
| Event 2 | 5/1/2025 | 0.5 | Type 2 |
| Event 5 | 2/1/2025 | 4 | Type 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:
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
- Ashish_MathurSuper User
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.
- PowerAutomaterHelper IV
This worked, and then I used the new column in the legend instead of the existing category. Thank you
- Ashish_MathurSuper User
You are welcome.
- lbendlinSuper User
Create a group over the Category field. Group 1 and 2 together and all others by themselves. Use the group as the legend.
- PowerAutomaterHelper IV
I'd like to try this but not quite sure what you mean. Are you able to provide a step by step please?