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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
HenryJS
Post Prodigy
Post Prodigy

Matrix: IF Column and Status Colours

Hi all,

 

I would like to create two calculate columns shown below:

  • 'Vehicle Status' - IF MOT or Service = Week Ending THEN MOT or Service Date ELSE "In Use"
  • 'Works' - IF MOT or Service = Week Ending THEN "MOT" or "Service

 

I then want to create a measure which dictates colours of MOT or Service in Works in a matrix

 

 

Vehicle Reg NumberWeek Ending - TextService MOTVehicle StatusWorks
CXZ 800214/02/2021 14/02/202114/02/2021MOT
GXZ 291827/09/202001/09/202027/09/202027/09/2020Service
GXZ309201/03/2020  In Use 
NV19 YJA01/03/2020  In Use 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @HenryJS ,

 

A little confusing, why the value of Works column for second row is "service"?

And what's your martix looks like?

Here's my formula for you reference.

Vehicle Status = IF('Table'[Week Ending - Text]='Table'[Service ],'Table'[Service ],IF('Table'[Week Ending - Text]='Table'[MOT],'Table'[MOT]))

Works = IF('Table'[Week Ending - Text]='Table'[Service ],"service",IF('Table'[Week Ending - Text]='Table'[MOT],"mot"))

4.PNG

And you could create a measure like 

measure = IF(selectedvalue('table'[works])="mot",1,0)

Then use conditional formatting:

When measure =1 then "red", when meausre = 2 then "green".

 

Best Regards,

Jay

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @HenryJS ,

 

A little confusing, why the value of Works column for second row is "service"?

And what's your martix looks like?

Here's my formula for you reference.

Vehicle Status = IF('Table'[Week Ending - Text]='Table'[Service ],'Table'[Service ],IF('Table'[Week Ending - Text]='Table'[MOT],'Table'[MOT]))

Works = IF('Table'[Week Ending - Text]='Table'[Service ],"service",IF('Table'[Week Ending - Text]='Table'[MOT],"mot"))

4.PNG

And you could create a measure like 

measure = IF(selectedvalue('table'[works])="mot",1,0)

Then use conditional formatting:

When measure =1 then "red", when meausre = 2 then "green".

 

Best Regards,

Jay

lkalawski
Super User
Super User

Hi @HenryJS 

Please use the code from @amitchandak  to create calculated columns and then you should create a measure to adjust colors for different values in the Works column:

 

Measure = 
SWITCH([Works M],
"MOT", "#FF0",
"Service", "#F0F"
)

 

And use it in the conditional formatting section for the Works column:

lkalawski_0-1599646654483.png

The Result:

lkalawski_1-1599646675520.png



_______________
If I helped, please accept the solution and give kudos! 😀

amitchandak
Super User
Super User

@HenryJS , Try new columns like

Vehicle Status - IF( [MOT] =[Week Ending] || [Service] = [Week Ending] , if([MOT] =[Week Ending] , [MOT] , [Service]) = [Week Ending] & "" , "In Use")
Works = IF( [MOT] =[Week Ending] || [Service] = [Week Ending] , if([MOT] =[Week Ending] , "MOT" , "Service"),blank())

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 this didn't work, is there a simpler way of restructuring the data that will allow me to bring more columns in at a later date?

 

Capture.PNG

@HenryJS ,

Try

Vehicle Status - IF( [MOT] =[Week Ending] || [Service] = [Week Ending] , if([MOT] =[Week Ending] , [MOT] , [Service]) & "" , "In Use")
Works = IF( [MOT] =[Week Ending] || [Service] = [Week Ending] , if([MOT] =[Week Ending] , "MOT" , "Service"),blank())

 

For conditional formatting create a measure and use that "Field Value" option

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 how can I add another column in? for example if I wanted to add another date field for 'Last Service'

 

thank you for your help

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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