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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply

To fix the color to the line chart based on the slicer selection

Hi Team,

Power bi Data Source

DateStockNameNameValue
7/19/2024RelienceEPS10.67
7/19/2024RelienceGPS11.36
7/19/2024RelienceRPS12.05
7/19/2024RelienceNPS12.74
7/19/2024RelienceBPS13.43
7/19/2024MedicoEPS10.67
7/19/2024MedicoGPS7.91
7/19/2024MedicoRPS5.15
7/19/2024MedicoNPS2.39
7/19/2024MedicoBPS13.43
7/19/2024BPOEPS24.47
7/19/2024BPOGPS35.51
7/19/2024BPORPS46.55
7/19/2024BPONPS57.59
7/19/2024BPOBPS68.63
7/18/2024RelienceEPS8.9
7/18/2024RelienceGPS11.36
7/18/2024RelienceRPS13.82
7/18/2024RelienceNPS16.28
7/18/2024RelienceBPS18.74
7/18/2024MedicoEPS21.2
7/18/2024MedicoGPS23.66
7/18/2024MedicoRPS26.12
7/18/2024MedicoNPS28.58
7/18/2024MedicoBPS31.04
7/18/2024BPOEPS33.5
7/18/2024BPOGPS35.96
7/18/2024BPORPS38.42
7/18/2024BPONPS40.88
7/18/2024BPOBPS43.34

 

 

i have a stock name as in the slicer

and in the line graph i have put
xaxis-Date
yaxis-Value
Legent-StockName


requirement

when we select first stock from the slicer then it should give marun colur in the line chart and when i select more than one stock then it sould give me grey colur to the second stock , basically user willl select only two stocks most of the times becuase he just need to do comparision between two stocks

and the same color should apply to table matrix it means in the column will give the same color as in the line chart
rows-Name
Columns-StockName
Values-RecentValue

RecentValue =
VAR SelectedTradeDate = SELECTEDVALUE(DASCaptured[Date])
VAR SelectedInstrument = SELECTEDVALUE(DASCaptured[StockName])
VAR SelectedName = SELECTEDVALUE(DASCaptured[Name])
VAR MaxDate =
CALCULATE(
MAX(DASCaptured[Date]),
FILTER(
ALL(DASCaptured),
DASCaptured[Date] <= SelectedTradeDate &&
DASCaptured[StockName] = SelectedInstrument &&
DASCaptured[Name] = SelectedName
)
)
RETURN
CALCULATE(
MAX(DASCaptured[CValue]),
FILTER(
ALL(DASCaptured),
DASCaptured[Date] = MaxDate &&
DASCaptured[StockName] = SelectedInstrument &&
DASCaptured[Name] = SelectedName
)
)



Thanks

2 REPLIES 2
amitchandak
Super User
Super User

@anshenterprice , As of now we can not control the color of line based on conditions. It can not change based on the measure.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  is there any other solution ? becuase we have three visual in the page
1 TableMatrix and two line chart 
when we select two stocks from the slicer then it should give the same color for tablematrix and the other two line charts everytime 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors