Format the Output

Hi ,

I have scenario where my measure return value with some string which i have concatenate with it i want to highlight the number.

For example : my measure return : Sale is 250M
then i want to colour the number(250M) so it appear different from the rest

pls, help me in this .

Thanks,
Anurag

@Anurag,

I would create a simple conditional formatting measure like this:

CF Sales =
IF( [Sales] < 0, “Red”, “Black” )

If you wanted more precision in the color to match your theme, you could substitute the specific hex codes where I have “Red” and “Black”.

Then go to Conditional Formatting and choose the “Field Value” option and then select this measure. (You can use this same measure regardless of whether you want to conditionally format the background or the font of your numbers.)

I hope this is helpful.

  • Brian

Thanx for the reply but my measure return the the string with number as i quoted above and when i apply conditional formatting it will apply to full output of my measure and i just want to colour the number part.

correct me i am missing some thing.

I am asking this question becuz my text is also dynamic in nature i can not make it hard codded.

@Anurag,

OK, the way i would handle that is to create a measure like this,

Total Sales M = 
DIVIDE(
    SUM ( Sales[Line Total] ),
    1000000
) 

And then apply a custom format string like this:

image

That way, your CF measure will still work.

  • Brian

@Anurag,

Actually, in re-reading your response, I’m not sure exactly what you want the output to look like. If the above response doesn’t resolve your question, please attach a PBIX file and a mockup of the specific output you want to achieve.

Thanks.

  • Brian

Ok , For my question i do not think PBIX is required i am attaching my required output

image

i want to highlight the number and text is also dynamic will change on condition like increase /decrease

Note: If still need to upload the PBIX just let me know

Hi @Anurag,

I think you should look into the smart narritives visual.
That will allow you to set a different format for your measures, if you want to highlight them. Here’s a link to the documentation.

@Anurag,

OK, I don’t think Smart Narrative will work here because I don’t think it yet supports conditional formatting. However, you can use the field value conditional format measure I specified above in a card visual, combined with another text-based card visual to accomplish your desired result . Here, I have the measure set to change the text to red if my sales measure is below $5 million.

Snag_b48132b

Snag_b49eb46
Full solution file attached below.

1 Like

I am come up with the same approach but it gone be more text box as i have already good number of visual on my page .

If there is no other way I will implement it with the text box idea.

thanks for answering my query

Hi @Anurag. I had another thought about conditional formatting a text string inside Power BI: you could use the HTML Custom Visual from AppSource. You can use a simple measure like this to compose the HTML of the text you’d like to display along with colours, fonts, whatever, then simply add it to the custom visual.

Here’s what my quick test looks like:

Here’s my quick test HTML measure:

Channel and Sales HTML = 
VAR _Header = "<html><body>"
VAR _Footer = "</body></html>"
VAR _NumberOfChannelsSelected = COUNTROWS( Channels )
VAR _Body1 = "There are multiple channels selected"
VAR _Body2a = "<span style=""color: blue"">Selected Channel = "
VAR _Body2b = MAX( Channels[Channel Name] ) & "</span>"
VAR _Body2c = "<span style=""color: red"">Total Sales = "
VAR _Body2d = [Sales] & "</span>"
VAR _Body2 = _Body2a & _Body2b & "<br>" & _Body2c & _Body2d
VAR _Result = _Header & IF( _NumberOfChannelsSelected <> 1, _Body1, _Body2 ) & _Footer

RETURN
_Result

Hope it helps.
Greg
eDNA Forum - Format Output.pbix (440.8 KB)

3 Likes

@Greg,

Super cool… I’ve never played with this particular custom visual before, but will definitely give it a look now. You mentioned font settings – do you know whether it lets you bring in fonts not native to Power BI?

Thanks.

  • Brian

I’d imagine so … I’d guess anything that can be rendered in HTML would show as if on a web page. It’s my first time trying this custom visual, so can’t say for sure …
Greg

Thanx , will try my hands on this visual .