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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. 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.

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
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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