Forum Discussion
Line chart X Axis and Y Axis problem
Hi All~
I am new in Power BI.
I want to make a Line Chart with below data, an example line chart is made by excel.
However Power BI not same as excel can set the X Axis range by user. So can below data trasfer to Line chart in Power BI?
Many Thanks
Anonymous ,
Follow the below steps,
1. Go to Power Query Editor and select highlighted columns in the image and do unpivot other columns (refer the image attached).
2. Go to conditional column and create a column named index and change the data type to whole number (this is being used to sort the month names chronoligically)
Jan-Dec : 1-12M code for conditional column:
= Table.AddColumn(#"Unpivoted Other Columns", "Index", each if [Attribute] = "Jan" then 1 else if [Attribute] = "Feb" then 2 else if [Attribute] = "Mar" then 3 else if [Attribute] = "Apr" then 4 else if [Attribute] = "May" then 5 else if [Attribute] = "Jun" then 6 else if [Attribute] = "Jul" then 7 else if [Attribute] = "Aug" then 8 else if [Attribute] = "Sep" then 9 else if [Attribute] = "Oct" then 10 else if [Attribute] = "Nov" then 11 else if [Attribute] = "Dec" then 12 else null)3. Create a calculated column for legends (use the below code)
Asset & ID = 'Test Table'[Asset] & " "&"Project "&'Test Table'[project_relation_id]4. Use the below metrics in line chart (refer the image)
5. To sort the month column chronoligcally - select the attribute(month name) then go to sort by column option then use index,
Thanks,
Arul
3 Replies
- ArulSuper User
Anonymous ,
Follow the below steps,
1. Go to Power Query Editor and select highlighted columns in the image and do unpivot other columns (refer the image attached).
2. Go to conditional column and create a column named index and change the data type to whole number (this is being used to sort the month names chronoligically)
Jan-Dec : 1-12M code for conditional column:
= Table.AddColumn(#"Unpivoted Other Columns", "Index", each if [Attribute] = "Jan" then 1 else if [Attribute] = "Feb" then 2 else if [Attribute] = "Mar" then 3 else if [Attribute] = "Apr" then 4 else if [Attribute] = "May" then 5 else if [Attribute] = "Jun" then 6 else if [Attribute] = "Jul" then 7 else if [Attribute] = "Aug" then 8 else if [Attribute] = "Sep" then 9 else if [Attribute] = "Oct" then 10 else if [Attribute] = "Nov" then 11 else if [Attribute] = "Dec" then 12 else null)3. Create a calculated column for legends (use the below code)
Asset & ID = 'Test Table'[Asset] & " "&"Project "&'Test Table'[project_relation_id]4. Use the below metrics in line chart (refer the image)
5. To sort the month column chronoligcally - select the attribute(month name) then go to sort by column option then use index,
Thanks,
Arul
- AnonymousNot applicable
hi, Arul.
Thanks for your help, so that if want to use Power BI to create Line chart, seem the excel data set format need to be changed. I can create the Line Chart by following your steps.
Cheer,
Joan
- ArulSuper User
Anonymous ,
Not always, It depends on the structure of your data.