Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Adumio
Frequent Visitor

Line chart with two curves, one for all, one is a continuous smaller part of the first curve.

Hello everyone,

 

I have a sample table (Table1) with three columns, X, Y, and Z, and let's say 20 rows from 1 to 20. In the Z column, the values are "Za" from row 1 to row 10, and "Zb" from row 11 to row 20. 

I'm trying to create a Line chart with two curves:

- one curve of values in column Y vs. X for all Z values (20 rows).

- one curve of values in column Y vs. X for selectable Z values, either Za or Zb. This curve is plotted on the same visual with a thicker width and different colour with the first curve.

Would you please help advise how I can do it?

Thank you,

Adumio.

 

3 REPLIES 3
Adumio
Frequent Visitor

I have figured out a way to do it. I copied and pasted the visual, applied the slicer filter to only one visual (Format, Edit Interactions, None), made the background become transparent, put it in front of the first visual. The new measure is actually unnecessary. It could be done with the original measures of X and Y.

Adumio_0-1710858407792.png

I still hope that someone can help me with a better way with just one visual.

 

Thank you.

 

 

Adumio
Frequent Visitor

Hello AnalyticsWizard,

 

Thanks you very much for your instructions. It's quick and detailed. The formula for Y_Selected_Z is definitely helpful.  

However, there is still a hiccup. When I plot the chart, Y_All_Z curve was also filtered by the Slicer (see below).

Adumio_6-1710691525283.png

Probably, the formula for Y_All_Z needs to be changed. I have tried the formula below but it didn't work.

"Y_All_Z = CALCULATE(AVERAGE(Table1[Y]), ALL(Table1[Z]))"
 

Would you please suggest?

 

The data table is below.

XYZ
12Za
24Za
36Za
48Za
510Za
612Za
714Za
816Za
918Za
1020Za
1122Zb
1224Zb
1326Zb
1428Zb
1530Zb
1632Zb
1734Zb
1836Zb
1938Zb
2040Zb

 

Below is the chart I made by Excel.

Adumio_5-1710690777748.png

Thank you for your kind help,

Adumio.

 

AnalyticsWizard
Solution Supplier
Solution Supplier

To create a line chart with the specified requirements in Power BI, follow these steps. This solution involves creating measures for the overall data and for selectable Z values, then using these measures in a line chart visual.

Step 1: Create Measures

First, you'll need to create measures to calculate the Y values for both scenarios: one for all Z values and one for selectable Z values.

Measure 1: Y for All Z Values
This measure will represent the Y values across all Z values. Since you want all rows included, this could simply be the sum or average of Y, depending on what exactly you want to plot. If Y is just to be plotted as is, you might not need a measure for this, but here's how you could define an average:

```DAX
Y_All_Z = AVERAGE(Table1[Y])
```

Measure 2: Y for Selectable Z Values
This measure will be dynamic based on the selection of Z values (Za or Zb). You'll need to use a slicer for Z values to make them selectable. The measure will adjust based on the slicer selection:

```DAX
Y_Selected_Z = CALCULATE(AVERAGE(Table1[Y]), FILTER(Table1, Table1[Z] = SELECTEDVALUE(Table1[Z])))
```

Step 2: Add a Slicer for Z Values

1. From the Visualizations pane, add a **Slicer** to your report.
2. Drag the Z column from Table1 into the Field box of the slicer. This will allow you to select Za or Zb dynamically.

Step 3: Create the Line Chart

1. Add a **Line Chart** from the Visualizations pane.
2. Drag the X column to the Axis field.
3. Drag both measures (`Y_All_Z` and `Y_Selected_Z`) to the Values field. Power BI will automatically plot them as separate lines.
4. Adjust the formatting of each line under the Format pane to differentiate them. You can change the color and increase the stroke width of the `Y_Selected_Z` line to make it stand out as requested.

Step 4: Customize Your Chart

- Under the **Format** options of the line chart, you can find settings to adjust the line width, color, and add data labels for clarity.
- Ensure your slicer is clearly visible and instruct users that they can select Za or Zb to change one of the curves dynamically.

With these steps, you should have a line chart that plots all Y values against X for all Z values and another curve that dynamically changes based on the selection of Z values (Za or Zb) through the slicer, meeting the requirements described in your post.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.