Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello experts,
I'm getting data like - I need <red>help<red>from you.
I need to show the output as - I need help from you.
Here the word help should be in red color. Like this based on the input color given in the data PBI need to apply that color to the word automatically and delete <red> <red> in the output.
Any suggestions please.
Thanks in advance.
Solved! Go to Solution.
Hi @Sairokkam
To expand further on this, if you have different words requiring different colors, e.g.
I need <red>help<red> from you, <green>please<green>
You can use Power Query to replace the <red> and <green> tags with the corresponsding HTML and CSS styles. It just requires doing some Replace values steps, giving this
So this defines CSS styles called red and green and applies these to the relevant words.
Regards
Phil
Proud to be a Super User!
Hi @Sairokkam
To expand further on this, if you have different words requiring different colors, e.g.
I need <red>help<red> from you, <green>please<green>
You can use Power Query to replace the <red> and <green> tags with the corresponsding HTML and CSS styles. It just requires doing some Replace values steps, giving this
So this defines CSS styles called red and green and applies these to the relevant words.
Regards
Phil
Proud to be a Super User!
Hi @Sairokkam
I didn't quite get the question the first time, sorry. Now I do - see the PBIX I linked to.
Using Power Query you can replace the <red><red> tags with the HTML/CSS you need to display the word using the HTML Content visual
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8lTIS01NUYgpNTAwTi5KTQEzUjNScwrQhBTSivJzFSrzS5ViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Message = _t]),
#"Replaced Value" = Table.ReplaceValue(Source," <red>","<style> span {color:#ff0000;} </style><span> ",Replacer.ReplaceText,{"Message"}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value","<red> ","</span> ",Replacer.ReplaceText,{"Message"})
in
#"Replaced Value2"
Now you don't need any DAX, you can just add the text to the HTML visual and see the color correctly
Regards
Phil
Proud to be a Super User!
Hi @Sairokkam
If you use this visual HTML Content - Custom Visual for Power BI (html-content.com) you can do it.
After installing the visual, add one to the page.
I've set up a dummy measure
HTML Measure =
VAR _Value = SELECTEDVALUE('DataTable'[Value])
VAR _Message = SELECTEDVALUE('DataTable'[Message])
VAR _StartText = "I need <style> span "
VAR _EndText = "</span> from you."
RETURN
IF ( _Value > 0, _StartText & "{color:#48e21a;} </style><span>" & _Message & _EndText, _StartText & "{color:#ff0000;} </style><span>" & _Message & _EndText )
to give this dependeing on the selected message
Text color is controlled by the hex color code e.g. #ff00000.
I don't know how you are getting these messages or how you decide what color to use. You'll need to modify your code to suit your needs. Post back if you need help.
Regards
Phil
Proud to be a Super User!
You'll need to display the text in a HTML visual like this one:
Introduction: Shielded HTML Viewer - Power BI Visuals by Nova Silva
or this one:
HTML Content - Custom Visual for Power BI (html-content.com)
or remove the tags:
Convert Data From HTML To Plain Text In Power BI (c-sharpcorner.com)
Proud to be a Super User!
Hey thanks for your reply.
I'm able to remove tags using this.
https://www.c-sharpcorner.com/article/convert-data-from-html-to-plain-text-in-power-bi/
But the color menctioned in the tag needs to apply to the word automatically. Any suggestions.
Hmmm...
I don't recognise <red>help<red> so I'm afraid that suggestions I might give might take you down a rabbit hole...
Red is a valid CSS colour CSS Colors (w3schools.com) so you could potentially look at doing some find and search functions with power query and dax.
Proud to be a Super User!
User | Count |
---|---|
93 | |
83 | |
77 | |
71 | |
65 |
User | Count |
---|---|
114 | |
101 | |
96 | |
65 | |
60 |