Power Bi line chart (Helpful tutorial)

In this Power bi tutorial, we will learn What is Power Bi line chart, how to create a line chart in Power BI, and also we will learn

  • How to create a power Bi line chart?
  • Power Bi line chart month and year
  • Power Bi line chart multiple lines
  • Power Bi line chart multiple values
  • Power Bi line chart show zero values
  • Power Bi line chart marker color based on the value
  • Power Bi line chart secondary value
  • Power Bi line chart secondary axis

What is Power Bi line chart?

In Power Bi line chart is a series of data points represented by dots, connected by a straight line.

Line chart in power bi having one or many lines. It is having an X-axis and Y-axis. In Power Bi, the line chart is usually used to visualize data over time.

Read: How to create Power BI report from SharePoint list and Power Bi Bar Chart.

How to create a Power Bi Line chart?

Here we will see how to create a line chart in power bi desktop.

  • Open your Power Bi desktop
  • Upload data from the Get Data in Power Bi. Here we are using the Sales Data. and you can download the data from here.
Sales data in excel sheet
Sales data in excel sheet
  • Go to the report on Power bi desktop.
  • Then select a line chart from the visualization pane
line chart in power bi desktop
line chart in power bi desktop
  • Then in the field formatting section in the visualization pane, under Axis select the Date->Month, and in the value-> Sales.
field formatting in power bi
field formatting in power bi

Now you can see the Line chart visualization in Power BI on the basis of Sales by month.

power bi line chart
power bi line chart

This is how to create a Power Bi Line chart.

Read: Power BI Pie Chart

Power Bi line chart month and year

Here we will see how to create line chart visualization using month and year in Power Bi. We will use the above data to create line chart visualization.

To create a line chart visualization, open the Power bi Desktop and load the data. Then

  • Select the Line Chart, from the visualization in Power Bi.
  • From the Fields formatting section, drag the Order Date and put it on the Axis.
  • Then from the Date hierarchy select the Year and Month in the Field pane.
  • In the value field, Select the units delivered from the Fields pane.
power bi line chart by month and year
power bi line chart by month and year
  • Then go to Format Tab, Click on the X-axis.
  • The X-axis is divided into two types
    • Continuous: The Continuous axis is only applicable to numeric Data, like date and time. If we are using a continuous axis, then we don’t have control over the scale, which means if we are extending the date range or increasing the size of the chart, the scale automatically adjusts.
    • Categorical: The Categorical axis can use text or number, and also it levels every data point.
  • Select the Continuous X-axis under the Type.
how to change x axis to continuous in power bi
how to change x axis to continuous in power bi
  • Now click on the Fork icon present at the top of the Line chart visualization in the Power bi.
  • By clicking on the Fork icon, it will take one level down in the hierarchy.
  • That means here in the date hierarchy, it will first show the year, as we select the month and year for this visualization, once you click, it will go one level down in the date hierarchy and it will show month and year in the X-axis.
drill down in power bi
drill down in power bi

Now you can see the Power Bi line chart month and year having continuous X-axis.

Power Bi line chart month and year
Power Bi line chart month and year
  • Now we will see the Power Bi line chart month and year having categorical X-axis.
  • In the visualization pane-> Format section->X-axis-> Type-> Categorical.
  • In the below screenshot, you can see the Power Bi line chart month and year having categorical X-axis.
Power Bi line chart month and year having categorical X-axis
Power Bi line chart month and year having categorical X-axis

Read: How to Embed Power BI Report in SharePoint Online

Power Bi line chart multiple lines

Now we will see how to add multiple lines to Power Bi line chart using the above data.

  • Select the Power Bi Line chart from the visualization.
  • Then follow the above Power Bi line chart month and year to add the Date to the X-axis.
  • Then in the value -> profit and units delivered. This will show two lines one for the profit and another for the units delivered. Also, you can add more values in the value field to display the multiple lines in a line chart.
Power Bi line chart multiple lines
Power Bi line chart multiple lines

Now you can see the Power bi Line chart multiple lines based on profit and unit delivered by year and month.

power bi line chart multiples lines
power bi line chart multiples lines

Read: How to Create a Dashboard in Power Bi?

Power Bi line chart multiple values

Here we will see how to add multiple values in line chart by using the above data.

  • Select the line chart from the visualization.
  • As we do in the power Bi multiple lines, in the same way, we will add multiple values i.e Units Delivered, profit, and discount -> value and order date -> Axis.
Power Bi line chart multiple values
Power Bi line chart multiple values
  • Now you can see the Power Bi line chart multiple values based on units delivered, profit, and discounts by Month.
Power Bi line chart multiple values
Power Bi line chart multiple values

Power Bi line chart show zero values

Here we will see, how to show zero value in Power Bi line chart using the above data set.

  • Select the Line chart from the Visualization in Power Bi.
  • We will use the Product name -> Axis field and the Discount -> value field.
  • In the discount data column in the excel sheet, no data means “null” and zero means 0.
  • Now you can see the line chart when the X-axis is categorical.
Discount by product name in the Line chart
Discount by product name in the Line chart

In the above screenshot, zero value is not shown in the Y-axis.

To solve this problem we will create a measure i.e.

Total discount = IF(ISBLANK(SUM(Sales_Table[Discount])),0,SUM(Sales_Table[Discount]))

According to your data, you can change your measure.

Then change the value field-> total discount.

After applying the measure, now you can see the zero value shown in the Y-axis of the Power Bi line chart.

power bi line chart show zero value.
power bi line chart show zero value.

Read: Microsoft Power bi report vs dashboard

Power Bi line chart marker color based on value

Here we will see how to create a Power Bi line chart marker color based on value by using the above excel data.

There is no straightforward option to create the Power Bi line chart marker color based on the value, we can do that by using the stacked column chart conditional formatting.

  • Select stacked column chart from the visualization pane in Power Bi.
  • Select the order date -> Axis and Quantity -> value in the field section.
Stacked column chart visualization
Stacked column chart visualization
  • Select the Format -> Data colors in the visualization pane.
  • Then click on the fx icon in the Default color section to apply conditional formatting.
conditional formatting power bi
conditional formatting power bi
  • Under Format by, select Rules.
power bi conditional formatting based on rules
power bi conditional formatting based on rules
  • Under Based on Field, Select the Quantity.
power bi conditional formatting based on field value
power bi conditional formatting based on field value
  • Then we will add rules to format the data colors in a stacked column chart visualization
  • If the value is greater than 0 and is less than 80, then select a color from the color pane.
  • Click on the New Rule to add another rule.
adding a new rule to the data colors column formatting
adding new rule to the data colors column formatting
  • If the value is greater than 20 and less than 80, then select a color from the color pane.
  • Click on OK.
power bi data colors conditional formatting
power bi data colors conditional formatting

Now you can see marker color based on the value in stacked column chart.

power bi marker color based on the value in column chart
power bi marker color based on the value in column chart

Now convert the stacked column chart into Line chart.

In the below screenshot you can see the Power BI line chart marker color based on the value.

Power Bi Line chart marker color based on the value
Power Bi Line chart marker color based on the value

Power Bi line chart secondary value

Here we will see how to get Power Bi line chart secondary value.

  • Click on the line chart from the visualization pane in Power bi desktop
  • In the Field format section, Axis-> Order date, value-> Quantity, Secondary values-> profit.
secondary values power bi
secondary values power bi
  • Now you can see the power bi line chart secondary value in right side if the Y-axis
power bi line chart secondary value
power bi line chart secondary value

Read: How to create Power BI report from SharePoint list

Power Bi line chart secondary axis

Here we will see about the Power Bi line chart secondary axis.

  • Click on the line chart from the visualization pane in Power bi desktop.
  • In the Field format section in visualization pane, Order date->Axis, Quantity-> values, and profit->Secondary values.
secondary values power bi
secondary values power bi
  • Then in the Format section in turn on the secondary axis.
  • In the secondary axis setting, you can set the start range and end range
  • Then we can set the Scale type
  • You can set the color, text size, and font family of the Secondary axis.
Secondary axis in Power bi
Secondary axis in Power bi
  • You can set the display units of the secondary axis.
  • Under the Title section, you can set the title of the secondary axis
  • Under Style, you can set the style the title of the secondary axis.
  • You can set the Title color, Axis title, title color, title text size, and title font family.
power bi secondary y axis title
power bi secondary y axis title

Now you can see the Power Bi line chart secondary axis based on Quantity and Profit by year and month.

Power Bi line chart secondary axis
Power Bi line chart secondary axis

You may also like:

In this Power Bi tutorial, we learned What is Power Bi line chart. And also we discussed how to create a Power Bi line chart?

By using the sample data we created:

  • Power Bi line chart month and year
  • Power Bi line chart multiple lines
  • Power Bi line chart multiple values
  • Power Bi line chart multiple values and legend
  • Power Bi line chart show zero values
  • Power Bi line chart marker color based on the value
  • Power Bi line chart secondary value
  • Power Bi line chart secondary axis
>