Often you may want to create a line chart in Power BI that shows the cumulative values of some variable over time.
The following step-by-step example shows how to create the following cumulative line chart in Power BI:
Let’s jump in!
Example: How to Create a Cumulative Line Chart in Power BI
Suppose we have the following table in Power BI named my_data that contains information about sales made on various dates by some company:
Suppose we would like to create a line chart that displays the cumulative sales over time.
Before we can create the line chart, we must add a new column that contains the cumulative sum of the values in the Sales column.
To do so, click the Table tools tab along the top ribbon, then click the New column icon:
Then type the following formula into the formula bar:
Cumulative Sales = CALCULATE ( SUM ( 'my_data'[Sales] ), ALL ( 'my_data' ), 'my_data'[Date] <= EARLIER ( 'my_data'[Date] ) )
This will create a new column named Cumulative Sales that contains the cumulative sum of the values in the Sales column:
To create a line chart that displays the values in the Cumulative Sales column, click the Report View icon on the left hand side of the screen:
Then, on the right side of the screen under Visualizations, click the Line chart icon:
An empty line chart will be inserted:
Next, drag the Date variable under the X-axis label, then drag the Cumulative Sales variable under the Y-axis label:
This will produce the following line chart:
The x-axis displays the date and the y-axis displays the cumulative sales.
The following tutorials explain how to perform other common tasks in Power BI: