Forum Discussion

MichaelRensing's avatar
7 months ago
Solved

Build custom HTML with formula

Howdy   I am working on a dashboard. I have a list of items, and am building drill through pages to display data about each item.  I have about 20 TRUE/FALSE columns on each item indicating wether ...
  • Amar_Kumar's avatar
    7 months ago

    You cannot append content to a column dynamically. This must be done with a measure. Best approach is to build the HTML in a DAX measure and render it using an HTML visual.

    Example measure:

    Image_HTML =

    VAR Img1 = IF (SELECTEDVALUE ( Items[Group1] ) = TRUE (),
    "<img src='https://url1.png' style='height:30px;margin-right:5px;'/>","")
    VAR Img2 = IF (
    SELECTEDVALUE ( Items[Group2] ) = TRUE (),
    "<img src='https://url2.png' style='height:30px;margin-right:5px;'/>","")
    VAR Img3 = IF (
    SELECTEDVALUE ( Items[Group3] ) = TRUE (),
    "<img src='https://url3.png' style='height:30px;margin-right:5px;'/>", "")
    RETURN Img1 & Img2 & Img3

     

    Use this measure in an HTML Content visual on the drillthrough page.

     

    This works because:

    • Measures are evaluated per selected item

    • HTML can be concatenated conditionally

    • Only images for TRUE columns are shown

    For a cleaner long-term model, unpivot the TRUE/FALSE columns and store image URLs in a lookup table