Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MiaSunny
Regular Visitor

How to build a line chart with multiple lines from dynamic table/ measures

Hi, 

 

I am currently building an automation with Power BI from an Excel file like below:

 

Sales2022-20232023-20242024-2025
Q16374113
Q21435 
Q324178 
Q410068 

 

base on the sales data we could get a cumulative table: 

Q2 YTD = Q1 sales+ Q2 sales ... etc.

 2022-20232023-20242024-2025
Q1 YTD6374113
Q2 YTD77109

113

Q3 YTD101287113
Q4 YTD201355113

 

Select the table and insert a line chart 

MiaSunny_1-1738690741563.png

 

I am having issue on rebuilding this into Power BI since a line chart needs a measure for each line, I will have to build a new measure each year which isn't sound like a good plan. Wondering if we have a way to build a line chart ( or other charts if works) from a table instead of a few measures. 

The table should be transformed then we will have Quarters as columns and years as rows which are more dynamic, but is it easier to build the lines by measures? by using the transformed table Excel could generate the same chart while I have no idea on how to use a table to feed the Line chart.  

 

 Q1 YTDQ2 YTDQ3 YTDQ4 YTD
2022-20236377101201
2023-202474109287355
2024-2025113113113113

 

Thank you for reading and any comment is appreciated! 

 

1 ACCEPTED SOLUTION
uzuntasgokberk
Super User
Super User

Hello @MiaSunny ,

İf you'd like to use few of measure or none. You can use legend option but your table needs to be fitted for the case. For example for your case you can unpivot the column Q1,YTDQ2,YTDQ3,YTDQ4,YTD in transform data(power query). Lastly, your table needs to be like this:

Year Att Val
2022-2023 Q1 63
2022-2023 YTDQ2  77
... ... ...
2024-2025 YTD 113


In the line chart, X-axis will be year, Y-axis will be Val, Legend will be Att.

 

Kind Regards,
Gökberk Uzuntaş

📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |

View solution in original post

2 REPLIES 2
rohit1991
Super User
Super User

Hi @MiaSunny , You can follow these steps to create the line chart.

Steps:

  1. Unpivot Data in Power Query

    • Select "Q1 YTD" to "Q4 YTD" → Transform > Unpivot Columns
    • Rename columns:
      • "Year" (Original year names)
      • "Quarter" (Q1 YTD, Q2 YTD, etc.)
      • "Sales" (Values)
  2. Create Line Chart

    • X-Axis: "Quarter"
    • Y-Axis: "Sales"
    • Legend: "Year"

Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
uzuntasgokberk
Super User
Super User

Hello @MiaSunny ,

İf you'd like to use few of measure or none. You can use legend option but your table needs to be fitted for the case. For example for your case you can unpivot the column Q1,YTDQ2,YTDQ3,YTDQ4,YTD in transform data(power query). Lastly, your table needs to be like this:

Year Att Val
2022-2023 Q1 63
2022-2023 YTDQ2  77
... ... ...
2024-2025 YTD 113


In the line chart, X-axis will be year, Y-axis will be Val, Legend will be Att.

 

Kind Regards,
Gökberk Uzuntaş

📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.