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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Color code in DAX

hi PBI, Can you help with coding a DAX with color code. Can I insert a color code into the DAX so it comes out in RED or Green visually

eg below

Change = if([Growth])>0,"Grow","Decline")

 

Growth   |   Change

0.12         |  Grow     <auttomatically green in color

-0.04        |  Decline       <automatically red in color

1 ACCEPTED SOLUTION
vanessa
Post Patron
Post Patron

@Anonymous

Color coding in DAX is not possible, but as a workaround you can create two metrics:

metric1=if([Growth])>0,"Grow","")

metric1=if([Growth])<=0,"Decline","")

 

Add two card visuals to the report and pull metric1 into 1 card and metric2 into the other card. Now, change the font color for 1st card(where metric1 has been used) to green and 2nd card(where metric2 has been used)  to red.

 

In this way, card 1 will show up only when [Growth])>0 and card 2 will show up only when [Growth])<=0

View solution in original post

7 REPLIES 7
vanessa
Post Patron
Post Patron

@Anonymous

Color coding in DAX is not possible, but as a workaround you can create two metrics:

metric1=if([Growth])>0,"Grow","")

metric1=if([Growth])<=0,"Decline","")

 

Add two card visuals to the report and pull metric1 into 1 card and metric2 into the other card. Now, change the font color for 1st card(where metric1 has been used) to green and 2nd card(where metric2 has been used)  to red.

 

In this way, card 1 will show up only when [Growth])>0 and card 2 will show up only when [Growth])<=0

By creating "metric" do you mean adding new measure?

 

What do you mean by "pull metric1 into 1 card and metric2 into the other card"?

@Gondebas

 

Yes add new measures.

 

I meant display measure1 on 1 card and measure2 on the other card.

By creating "metric" do you mean adding new measure?

 

What do you mean by "pull metric1 into 1 card and metric2 into the other card"?

Anonymous
Not applicable

thanks.... although not ideal but works and i am using it now

v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

Current dax formula not support color code, I think you can post this requirement to ideas forum or use conditional formatting function to modify the display color.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Conditional Formatting was just added to the visuals recently (June Power BI).  It can't be used on the Text Entries but you could colour in the Growth column based on a range.

To do this, click on the Field in the Values area of your visualisations and select the down triangle to get the menu.  The menu has conditional formatting and Color Scales.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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