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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
amaniramahi
Helper V
Helper V

Single line chart with changing line color

Hi,

 

I have a table listing  three columns as below for the fuel level in the tank on different times during the day.

 

TimeStatusFuel Level*
11:42:23 AMMotion88.91
11:42:28 AMMotion88.91
11:42:33 AMMotion87.96
11:42:38 AMMotion87.96
11:42:43 AMMotion88.91
11:42:48 AMMotion87.96
11:42:53 AMMotion87.96
11:42:58 AMMotion88.74
11:43:03 AMMotion88.74
11:43:08 AMMotion88.74
11:43:13 AMMotion88.91
11:43:18 AMMotion88.91
11:43:23 AMMotion88.91
11:43:28 AMMotion88.74
11:43:33 AMMotion86.68
11:43:38 AMMotion86.68
11:43:43 AMMotion86.68
11:43:48 AMMotion86.84
11:43:53 AMMotion

86.84

 

11:55:11 AMMotion86.53
11:55:16 AMMotion86.53
11:55:21 AMMotion86.68
11:55:26 AMMotion87
11:55:31 AMMotion89.22
11:55:36 AMMotion89.22
11:55:41 AMIDLE OR OFF89.22
11:55:46 AMIDLE OR OFF87
11:55:51 AMIDLE OR OFF87
11:55:56 AMIDLE OR OFF87
11:56:01 AMIDLE OR OFF87
11:56:06 AMIDLE OR OFF86.84
11:56:11 AMIDLE OR OFF86.84
11:56:16 AMIDLE OR OFF87
11:56:21 AMIDLE OR OFF87
11:56:26 AMIDLE OR OFF87
11:56:31 AMIDLE OR OFF87
11:56:36 AMIDLE OR OFF87
11:56:41 AMIDLE OR OFF87
11:56:46 AMIDLE OR OFF87
11:56:51 AMIDLE OR OFF86.84
11:56:56 AMIDLE OR OFF86.84
11:57:01 AMIDLE OR OFF86.84
11:57:06 AMIDLE OR OFF86.84
11:57:11 AMIDLE OR OFF86.84
11:57:16 AMIDLE OR OFF86.84

 

12:25:07 PMMotion86.21
12:25:12 PMMotion85.89
12:25:17 PMMotion85.89
12:25:22 PMMotion85.89
12:25:27 PMMotion87.64
12:25:32 PMMotion88.11
12:25:37 PMMotion88.27
12:25:42 PMMotion88.27
12:25:47 PMMotion88.11
12:25:52 PMMotion87.48
12:25:57 PMMotion86.68
12:26:02 PMMotion86.68
12:26:07 PMMotion86.68
12:26:12 PMMotion86.68
12:26:17 PMMotion86.53
12:26:22 PMMotion86.53
12:26:27 PMMotion86.53
12:26:32 PMMotion86.68

 

12:32:07 PMMotion86.68
12:32:12 PMMotion87
12:32:17 PMMotion87
12:32:22 PMIDLE OR OFF87.16
12:32:27 PMIDLE OR OFF87.16
12:32:32 PMIDLE OR OFF87.16
12:32:37 PMIDLE OR OFF87.16
12:32:42 PMIDLE OR OFF87.16
12:32:47 PMIDLE OR OFF87.16
12:32:52 PMIDLE OR OFF87.16
12:32:57 PMIDLE OR OFF----
12:32:57 PMIDLE OR OFF87
12:32:58 PMIDLE OR OFF----
12:33:02 PMIDLE OR OFF87
12:33:07 PMIDLE OR OFF86.53
12:33:12 PMIDLE OR OFF85.73
12:33:17 PMIDLE OR OFF85.73
12:33:22 PMIDLE OR OFF85.73

 

I took sample from the table to show that there are times when the vehicle is in motion, other times it's ideling.

 

I need to make a  line graph visualization to show the fuel level during the two statuses 

But I need it to be a single line and the its color changes as the status changes.

 

 

1 ACCEPTED SOLUTION
nandukrishnavs
Super User
Super User

@amaniramahi -
conditional formatting feature is not supported in the default line chart. 


Below is the workaround. 


create a measure

format =
VAR _status =
    SELECTEDVALUE ( FuelTable[Status] )
VAR _color =
    IF ( _status = "Motion", "green", IF ( _status = "IDLE OR OFF", "red" ) )
RETURN
    _color

Use a clustered column chart and use conditional formatting. 

 

s.JPG

 

Then switch your bar chart with a line chart.

 

op.JPG

 



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 

 

 

 


Regards,
Nandu Krishna

View solution in original post

2 REPLIES 2
nandukrishnavs
Super User
Super User

@amaniramahi -
conditional formatting feature is not supported in the default line chart. 


Below is the workaround. 


create a measure

format =
VAR _status =
    SELECTEDVALUE ( FuelTable[Status] )
VAR _color =
    IF ( _status = "Motion", "green", IF ( _status = "IDLE OR OFF", "red" ) )
RETURN
    _color

Use a clustered column chart and use conditional formatting. 

 

s.JPG

 

Then switch your bar chart with a line chart.

 

op.JPG

 



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 

 

 

 


Regards,
Nandu Krishna

@nandukrishnavs Thank you so much! it worked !

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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