Forum Discussion

TrisBask's avatar
TrisBask
Regular Visitor
2 years ago
Solved

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.

  • Anonymous's avatar
    Anonymous
    2 years ago

    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

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

    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

    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

     

     

     

     

2 Replies

  • Anonymous's avatar
    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

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

    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

    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