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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Aidenn90
Frequent Visitor

Constant Y line based on slicer in Line graph

Hi,

 

I haver a line graph that shows various values based on date. There are two slicers used to control this graph.

 

Slicer #1: Date

Slicer #2: Type 

 

Is there there a way to create a measurement or function to have constant Y lines in a line graph adjust based on slicer #2. (Date should have no control over the data i want returned)

 

Example below:

 

Query 1  
TypeLSLUSL
A520
B621
C722
D823
E924
F1025

 

Query 2   
TypeDate Value
A1/1/1990 2
A1/2/1990 11
A1/3/1990 19
A1/4/1990 29
B1/1/1990 3
B1/2/1990 12
B1/3/1990 20
B1/4/1990 30
C1/1/1990 4
C1/2/1990 13
C1/3/1990 21
C1/4/1990 31
D1/1/1990 5
D1/2/1990 14
D1/3/1990 22
D1/4/1990 32

 

All my data comes from 'Query 2'. I have graphed [Value] against [Date], and use [Date] and [Type] as a slicer. I would like put a constant Y Axis Line using the [LSL]/[USL] column from 'Query 1' as it slices by Query1 [type].

 

Example of what My graph currently looks like. I would like the Dotted blue lines to change to new spec limits when i change the blue slicer from D to another letter. Currently they are set at 8 and 23, i would like them to automatically change to 5 and 20 when i got to Letter A, or 6/21 when i go to be, and so on and so forth. 

Aidenn90_1-1734028342569.png

 

 

 

 

 

 

Thanks,

 

1 ACCEPTED SOLUTION

Hi @Aidenn90 ,

If I understand your question correctly, the solution is fairly straightforward. You can create two measures for the constant lines (LSL and USL) using SELECTEDVALUE. These measures will dynamically adjust based on the Type selected in the slicer.

Here’s how you can do it:

Create Measures for LSL and USL:
Use the following DAX formulas to retrieve the values from Query 1 based on the slicer selection:

DAX
Copy code
LSL = SELECTEDVALUE('Query 1'[LSL])
USL = SELECTEDVALUE('Query 1'[USL])
Add Constant Lines to the Graph:
After creating these measures, you can add them as constant lines in the Analytics pane of your line chart (as shown in the attached image).

Ritaf1983_0-1734030830923.png

Ritaf1983_1-1734030879645.png

 

The pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

5 REPLIES 5
Ritaf1983
Super User
Super User

Hi @Aidenn90 

Can you show the desired result?

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi Rita, 

 

Thanks for the quick response. I have updated my original post with example of graph with constant Y-lines that i would like to change with my slicer.

Hi @Aidenn90 ,

If I understand your question correctly, the solution is fairly straightforward. You can create two measures for the constant lines (LSL and USL) using SELECTEDVALUE. These measures will dynamically adjust based on the Type selected in the slicer.

Here’s how you can do it:

Create Measures for LSL and USL:
Use the following DAX formulas to retrieve the values from Query 1 based on the slicer selection:

DAX
Copy code
LSL = SELECTEDVALUE('Query 1'[LSL])
USL = SELECTEDVALUE('Query 1'[USL])
Add Constant Lines to the Graph:
After creating these measures, you can add them as constant lines in the Analytics pane of your line chart (as shown in the attached image).

Ritaf1983_0-1734030830923.png

Ritaf1983_1-1734030879645.png

 

The pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Exactly what i needed, i was trying to make it more complicated then i needed to. Thank you

Happy to help💗

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

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.

Top Solution Authors