Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Create a multiple line chart per Country level

Hi All

 

I am learning power BI currently and had just started since 2 days ago. I am trying to figure out on how to create a line report which showing the values per quarter by country level.

Expected:

Sample data as follow:

Country
2019Q2
2019Q12018Q42018Q32018Q2
Vietnam543-21
Thailand67853
China234105
Cambodia54321
Indonesia-4-5431

 

I couldnt get it works unless I transposed the table into below:

CountryVietnamThailandChinaCambodiaIndonesia
2019Q25625-4
2019Q14734-5
2018Q438434
2018Q3-251023
2018Q213511

 

However if the table transposed as above, i couldn't add the country as filter, only quarter..

Is there any way to create the multiple Line chart per countries which filterable by the countries?

 

Thanks!

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Anonymous ,

     

    at first you need to unpivot the last 5 columns of your original data ( > Transform > Unpivot columns) so that you get a table like this:

     

    Country Quarter Value

    Vietnam2019Q25
    Vietnam2019Q14
    Vietnam2018Q43
    Vietnam2018Q3-2
    Vietnam2018Q21
    Thailand2019Q26
    Thailand2019Q17
    Thailand2018Q48
    Thailand2018Q35
    Thailand2018Q23
    China2019Q22
    China2019Q13
    China2018Q44
    China2018Q310
    China2018Q25
    Cambodia2019Q25
    Cambodia2019Q14
    Cambodia2018Q43
    Cambodia2018Q32
    Cambodia2018Q21
    Indonesia2019Q2-4
    Indonesia2019Q1-5
    Indonesia2018Q44
    Indonesia2018Q33
    Indonesia2018Q21

     

    With this query result you can create your multiple line visual and sort it by quarter:

     

    Voila!

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    at first you need to unpivot the last 5 columns of your original data ( > Transform > Unpivot columns) so that you get a table like this:

     

    Country Quarter Value

    Vietnam2019Q25
    Vietnam2019Q14
    Vietnam2018Q43
    Vietnam2018Q3-2
    Vietnam2018Q21
    Thailand2019Q26
    Thailand2019Q17
    Thailand2018Q48
    Thailand2018Q35
    Thailand2018Q23
    China2019Q22
    China2019Q13
    China2018Q44
    China2018Q310
    China2018Q25
    Cambodia2019Q25
    Cambodia2019Q14
    Cambodia2018Q43
    Cambodia2018Q32
    Cambodia2018Q21
    Indonesia2019Q2-4
    Indonesia2019Q1-5
    Indonesia2018Q44
    Indonesia2018Q33
    Indonesia2018Q21

     

    With this query result you can create your multiple line visual and sort it by quarter:

     

    Voila!

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks a lot for the solution! It works like a charm!

    Mariusz Anonymous 

  • Mariusz's avatar
    Mariusz
    Community Champion

    Hi Anonymous 

     

    Please see the attached file with the solution.

    All you need to do is use Unpivot on all Quarter column instead of the Transpose.

     

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    Mariusz Repczynski