Combine DAX, HTML and static Text
What makes the HTML Text Styler and HTML & CSS Viewer so powerful is the fact that you can combine DAX, HTML and static text. For example, you could use DAX to calculate the variance between Actuals and Budget and 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 Knowledge Base contains many specific samples of how to combine DAX, HTML and static text, but in this article we’ll focus on the basics. Knowing how DAX and HTML can be combined will make it much easier for you to use our visuals 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]
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>”
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]
Once you are familiar with these basics, you can start building more and more complex measures to make your report completely dynamic
Click here to learn how you can let the user dynamically change the font size
Click here to get introduced to some of the most common HTML tags for formatting (bold, italic, underline, etc.)