Combine DAX, HTML and static Text
What makes the HTML Text Styler so powerful is the fact that you can combine DAX, HTML and static text. You can use DAX to make the content dynamic. For example you could use DAX to calculate the variance between Actuals and Budget. And you can use HTML to add dynamic formatting. So you could format the variance between Actuals and Budget differently, depending on the value. You could format a positive variance green and a negative one red. This will make it very easy for the end-user to see what to focus on.
This Knowledge Base contains many specific samples of how to combine DAX, HTML and static text, but in this article we’ll focus on the very basics, without looking at a specific case. Knowing how DAX and HTML can be combined will make it much easier for you to use the visual in your reports.
How elements are combined
Whenever non-DAX elements like static Text or HTML code are combined with a DAX element, the & symbol needs to be placed in between the elements. Example 1 – You want to combine the static text “The variance is” with a value which is calculated in a DAX measure called”variance”. “The variance is “&[variance] Note: Also include all the spaces you want to show. In the measure above, there’s a space after the word “is”. Example 2 – You want to format the measure “Selected Country” bold “<b>”&[Selected Country]&“</b>” Example 3 – You want to format the measure “Selected Country” bold but also want to the static text “You have selected” in front “You have selected <b>”&[Selected Country]&“</b>” Note that static text and HTML can be within the same double quotation marks. Example 4 – You want to format the measure “Selected Country” bold but also want to the static text “You have selected” in front. Also, you want to add the measure “variance” in the end “You have selected <b>”&[Selected Country]&“</b> “&[variance]