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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
TrisBask
Regular Visitor

Multi-line line graph with multiple columns for the x axis

Hi all,

 

Quite new to Power BI. I am trying to plot some student results data (education setting) into a multi-line graph.

 

This is what my data looks like, it represents pass rates at different reporting periods (every 6 months, seperated into semester 1 and semester 2 for each year).

 

Year LevelSubject NameFaculty2024-Sem12023-Sem22023-Sem12022-Sem22022-sem1
1EnglishPrimary7976816876
1MathsPrimary8178787675
2EnglishPrimary8887858482
2MathsPrimary7979788182
7EnglishEnglish8887888785
7MathsMaths7575778183
8EnglishEnglish8080818079
8MathsMaths6572777981
10BiologyMaths6579887980

 

Ideally, I would like a line for each row in the table (subject/year level combination), plotting the different semester data points. This will show me trends for each year level/subject. When I have tried, I can't seem to get it to display what I am after.

 

I have tried putting each of my data columns into the X-axis, and the subject in the X-Axis, but that defaults to a count of the subjects which is not what I want.

 

When reversing this, I get a count of the semester results instead of just displaying their values.

 

I found a reference to Unpivot in my googling, but that didn't seem to help.

 

Any help is appreciated.

 

Thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @TrisBask ,
Thanks for @amitchandak  reply.
Based on your description, you want to create a line graph with multiple line segments, and those segments need to contain every piece of data. Since you want to show the trend of the data at different stages, you need to use the Year-Period field as the X-axis, so you need to turn these field names into values in the columns, where Unpivot is used.In Power BI line charts, we can only show categories in one field. So, we also need to use the Small Multiples field. Here are the detailed steps:
First, we need to merge columns in power query, hold Ctrl to select the Subject Name and Faculty fields

vheqmsft_0-1721094819317.png

vheqmsft_1-1721094900167.png

After creating the merged column, hold Ctrl to select all Year-Period fileds and unpivot them

vheqmsft_2-1721095019320.png

Close and apply and then you can create a line cahrt, you can slide the right slider to see the line graphs for different Subject Name-Faculty

vheqmsft_3-1721095062217.png

Best regards,
Albert He

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @TrisBask ,
Thanks for @amitchandak  reply.
Based on your description, you want to create a line graph with multiple line segments, and those segments need to contain every piece of data. Since you want to show the trend of the data at different stages, you need to use the Year-Period field as the X-axis, so you need to turn these field names into values in the columns, where Unpivot is used.In Power BI line charts, we can only show categories in one field. So, we also need to use the Small Multiples field. Here are the detailed steps:
First, we need to merge columns in power query, hold Ctrl to select the Subject Name and Faculty fields

vheqmsft_0-1721094819317.png

vheqmsft_1-1721094900167.png

After creating the merged column, hold Ctrl to select all Year-Period fileds and unpivot them

vheqmsft_2-1721095019320.png

Close and apply and then you can create a line cahrt, you can slide the right slider to see the line graphs for different Subject Name-Faculty

vheqmsft_3-1721095062217.png

Best regards,
Albert He

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

 

 

amitchandak
Super User
Super User

@TrisBask , In power query:  Unpivot all year-semester columns, and then split the new column with year-semester using split by delimiter into 2 columns. The format that you will get now should work

 

Power BI: Power Query Functions one must know: https://www.youtube.com/watch?v=cN8AO3_vmlY&t=36407s

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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