Setting Background Color Based on Dynamic RGB Values

Hello,

Is there a way it can automatically change the RGB background of report using a filter. Thank you in advance.

Drew

@andrew0101,

This is a really interesting question. Like many things in PBI, the technical answer is “no” (becase Page Background doesn’t have a conditional formatting option) , but the practical answer is that we can jury rig PBI elements to successfully mimic that effect.

In the solution attached, here’s what I’ve done:

  1. created three what-if parameters, Red, Green and Blue
  2. created three slicers corresponding to these parameters
  3. created a measure (based on a post by David Eldersveld) that harvests these parameters and converts the RGB value to a Hex code
  4. added a navigation button from this filter setttings page to a second page, and a back button on the second page to return
  5. put a page-sized blank button over top of the second page
    6 ) set the fill color of this blank button to the field value of the DAX measure in 3. above using field value conditional formatting
  6. Voila! Dynamic “background” color based on RGB parameter settings:

Here’s the DAX conversion measure:

RGB to Hex =

// Manually enter components of RGB decimal color value, e.g. "RGB(1,184,170)"

VAR RedDecimalColorValue = SELECTEDVALUE(Red[Red] )

VAR GreenDecimalColorValue = SELECTEDVALUE(Green[Green])

VAR BlueDecimalColorValue = SELECTEDVALUE(Blue[Blue])

//Decimal to Hex

VAR RedPosition0Dec = MOD(RedDecimalColorValue,16)

VAR RedPosition0Div = INT(RedDecimalColorValue / 16)

VAR RedPosition1Dec = MOD(RedPosition0Div,16)

VAR RedPosition1Div = INT(RedPosition0Div / 16)

VAR GreenPosition0Dec = MOD(GreenDecimalColorValue,16)

VAR GreenPosition0Div = INT(GreenDecimalColorValue / 16)

VAR GreenPosition1Dec = MOD(GreenPosition0Div,16)

VAR GreenPosition1Div = INT(GreenPosition0Div / 16)

VAR BluePosition0Dec = MOD(BlueDecimalColorValue,16)

VAR BluePosition0Div = INT(BlueDecimalColorValue / 16)

VAR BluePosition1Dec = MOD(BluePosition0Div,16)

VAR BluePosition1Div = INT(BluePosition0Div / 16)

VAR RedPosition0Hex = SWITCH(RedPosition0Dec,10,"A",11,"B",12,"C",13,"D",14,"E",15,"F",RedPosition0Dec)

VAR RedPosition1Hex = SWITCH(RedPosition1Dec,10,"A",11,"B",12,"C",13,"D",14,"E",15,"F",RedPosition1Dec)

VAR GreenPosition0Hex = SWITCH(GreenPosition0Dec,10,"A",11,"B",12,"C",13,"D",14,"E",15,"F",GreenPosition0Dec)

VAR GreenPosition1Hex = SWITCH(GreenPosition1Dec,10,"A",11,"B",12,"C",13,"D",14,"E",15,"F",GreenPosition1Dec)

VAR BluePosition0Hex = SWITCH(BluePosition0Dec,10,"A",11,"B",12,"C",13,"D",14,"E",15,"F",BluePosition0Dec)

VAR BluePosition1Hex = SWITCH(BluePosition1Dec,10,"A",11,"B",12,"C",13,"D",14,"E",15,"F",BluePosition1Dec)

VAR RGBDecimalColorAsHex = "#" & RedPosition1Hex & RedPosition0Hex & GreenPosition1Hex & GreenPosition0Hex & BluePosition1Hex & BluePosition0Hex

RETURN RGBDecimalColorAsHex

I hope this is helpful. Full solution file attached below.

  • Brian

eDNA Forum – RGB Background Solution.pbix (391.8 KB)

6 Likes

Hi @andrew0101, did the response provided by @BrianJ help you solve your query? If not, how far did you get and what kind of help you need further? If yes, kindly mark as solution the answer that solved your query.

I hope that you are having a great experience using the Support Forum so far. We’ve recently launched the Enterprise DNA Forum User Experience Survey, please feel free to answer it and give your insights on how we can further improve the Support forum. Thanks!

Hi @andrew0101, we’ve noticed that no response has been received from you since the 16th of April. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved.

Thank you @BrianJ, this is a new learning to me.