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
jcu
Frequent Visitor

How to specify 'ransparent' as a color in conditional fill Color on Button

Using Button with conditional formatting works very nicely most of the time,

 

BUT:

 

When I try to specify 'transparent' in the name of the color for background on an icon using a variable for conditional fill color, I get an error.

 

According to:

https://docs.microsoft.com/da-dk/power-bi/create-reports/desktop-conditional-table-formatting#color-...

Color by color values

If you have a field or measure with color name or hex value data, you can use conditional formatting to automatically apply those colors to a column's background or font color. You can also use custom logic to apply colors to the font or background.

The field can use any color values listed in the CSS color spec at https://www.w3.org/TR/css-color-3/. These color values can include:

  • 3, 6 or 8-digit hex codes, for example #3E4AFF. Make sure you include the # symbol at the start of the code.
  • RGB or RGBA values, like RGBA(234, 234, 234, 0.5).
  • HSL or HSLA values, like HSLA(123, 75%, 75%, 0.5).
  • Color names, such as Green, SkyBlue, or PeachPuff.

 

I would have expected transparent to work according to the css-colo-3 document:

 

4.2.3. transparent’ color keyword

CSS1 introduced the ‘transparent’ value for the background-color property. CSS2 allowed border-color to also accept the ‘transparent’ value. The Open eBook(tm) Publication Structure 1.0.1 [OEB101] extended the ‘color’ property to also accept the ‘transparent’ keyword. CSS3 extends the color value to include the ‘transparent’ keyword to allow its use with all properties that accept a <color> value. This simplifies the definition of those properties in CSS3.

transparent Fully transparent. This keyword can be considered a shorthand for transparent black, rgba(0,0,0,0), which is its computed value.

Maybe I joust need to specify the value in another way, '#800000' and 'red' both works.

 

/ Jens Chr

1 ACCEPTED SOLUTION

Using a measure like this is giving me an error also and telling me to send out a report.

 

With my previous experience when I sendon out the report I got a response from microsoft pretty quickly.

 

However if you take out the transparent part from the measure and use the transparency of the button fill the error goes away, in this case you can use the full colour with the measure and set the button fill transparency on the options.

 

Again just streching out the possibilities and trying to give alternatives, some may not work in some context but it's a trial and error.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

15 REPLIES 15
PaulDBrown
Community Champion
Community Champion

@jcu 

I wish you could set a transparency value in all colour formatting options (which you can't, unfortunately). Especially useful for example in scatter charts, where the larger (circular) values can cover smaller values. 
I actually submitted an "idea" for this a while ago in the ideas forum, but these kind of ideas never seem to get any traction





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi @PaulDBrown ,

 

Has you can see on the scatter chart you can also use this trick:

 

MFelix_0-1600090507719.png

 

 

Believe the idea did not had any traction because they imlpemented the condittional formatting, but agree with you would be better to have it native on the colour coding instead of condittional formatting or similar.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix 

Thanks for that, Miguel. Unfortunately the dataset I needed it for had over 200 possible IDs (it is -yet another- coronavirus report) and the scatter chart was by region and country/area and comparing cases per million and deaths per million (bubble size being total number of cases), so difficult to establish transparency levels either individually or by conditional format: the ideal setting would in this case be a "global" transparency level setting for all colours displayed.

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi @PaulDBrown ,

 

Maybe you can think outside of the box. I'm assuming you aren't setting the colour manually, so picking up this post by @Phil_Seamark  and making some adjustment on the way I get the information I was abble to get an automatic colour coding adding then a 50% transparency).

 

 

 

 

Condittional Formatting = 
VAR MaxR =
    MAXX ( SUMMARIZE ( 'Table'; 'Table'[CAt]; 'Table'[Value] ); 'Table'[Value] ) * 1000000000
-- 1000000000 this value is used to increase the spectre of colours the smaller the number the lower the nummber of colours.My values were between 100 and 1000 so the range was prety low in terms of colours
VAR MinR =
    MINX ( SUMMARIZE ( 'Table'; 'Table'[CAt]; 'Table'[Value] ); 'Table'[Value] ) * 1000000000
VAR R =
    ROUND ( ( MaxR - MinR ) + MinR; 0 )
VAR G =
    ROUND ( ( MaxR - MinR ) + MinR; 0 )
VAR B =
    ROUND ( ( MaxR - MinR ) + MinR; 0 )
VAR Base = 16
VAR BitTable =
    GENERATESERIES ( 1; 8 )
VAR DEC2HEXR =
    CONCATENATEX (
        BitTable;
        VAR c =
            MOD ( TRUNC ( R / POWER ( base; [value] - 1 ) ); base )
        RETURN
            SWITCH ( c; 10; "A"; 11; "B"; 12; "C"; 13; "D"; 14; "E"; 15; "F"; c );
        ;
        [Value]; DESC
    )
VAR DEC2HEXg =
    CONCATENATEX (
        BitTable;
        VAR c =
            MOD ( TRUNC ( G / POWER ( base; [value] - 1 ) ); base )
        RETURN
            SWITCH ( c; 10; "A"; 11; "B"; 12; "C"; 13; "D"; 14; "E"; 15; "F"; c );
        ;
        [Value]; DESC
    )
VAR DEC2HEXB =
    CONCATENATEX (
        BitTable;
        VAR c =
            MOD ( TRUNC ( B / POWER ( base; [value] - 1 ) ); base )
        RETURN
            SWITCH ( c; 10; "A"; 11; "B"; 12; "C"; 13; "D"; 14; "E"; 15; "F"; c );
        ;
        [Value]; DESC
    )
RETURN
    "#"
        & LEFT ( { DEC2HEXR } & { DEC2HEXG } & { DEC2HEXB }; 6 ) & "50"

 

 

 

 

Has you can see below the information gives out a different colour with 50% transparency for each colour, changing the scheme of the categories replace also the colours.

 

MFelix_1-1600096911574.png

Check PBIX file attach.

 

Not very conventional and measure may need some tweaking but can be one option 😉.

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix 

 

Pretty amazing work there Miguel! thanks for the effort! I'll give it a try (and hope we eventually get a nice little transparency slider in the near future...)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown ,

 

Been playing around and you probably need sometimes to first do the condittional formatting and then add the categories, but it's just a questions of order in the steps for sure you are used to it in other visualizations.

 

😂😂😂


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



jcu
Frequent Visitor

NICE!

 

but you cannot set the transparency level for a button fill.... must be a bug

 

/jens chr

Using a measure like this is giving me an error also and telling me to send out a report.

 

With my previous experience when I sendon out the report I got a response from microsoft pretty quickly.

 

However if you take out the transparent part from the measure and use the transparency of the button fill the error goes away, in this case you can use the full colour with the measure and set the button fill transparency on the options.

 

Again just streching out the possibilities and trying to give alternatives, some may not work in some context but it's a trial and error.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Greg_Deckler
Super User
Super User

@jcu Sorry, what is the purpose of a transparent color? Is this like drawing red lines with transparent markers?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

The reason for the transparent fill color would be to 'not show' a button depending on some other data on the page.

 

So you are right, the purpose is to make it disappear

 

/jens chr

jcu
Frequent Visitor

Title is wrong: should say TRANSPARENT

Hi @jcu ,

 

the transparent colours are definid trough HEX codes adding two digits in the end of the colour something similar to :

 

Conditional formatting = "#ffffff00"

 

The two 0 can be replace from values until 99 being 00 fully transparent.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



jcu
Frequent Visitor

Thx for the reply, but

 

When I use the code:

 

#ffffff00

 

rendering fails with 'Something went wrong"

 

Using  

 

#ffffff

 

works, but naturally is not transparent...

 

/jens chr

Hi @jcu ,

 

this must not be set on the colour formattign you need to add a measure with this coding.

 

I have created the following code:

Condittional formatting =
SWITCH (
    SELECTEDVALUE ( 'Table'[CAt] );
    "A"; "#118DFF00";
    "B"; "#118DFF25";
    "C"; "#118DFF50";
    "D"; "#118DFF75"
)

It's always the same  colour but with different levels, has you can see below the chart on tyhe left shows different condittional formaating from transparent to 75% and on the rigth you have it witouth the condittional formatting.

 

MFelix_1-1600089923757.png

Check PBIX file attach.

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Love this trick -thanks for sharing!

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.