Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply

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  they are a member of that columns grouping. So for instance, Item 1 may not be a member of any of the groupings, and all of the 2 columns would be FALSE. Item 2 may be a member of 1 of them, and one of the 20 columsn would be TRUE, the other 19 would be FALSE. Item 3 may be a member of 3 of them, having 3 columns with a TRUE value, the other 17 FALSE.

I have image URLS for each of the columns. I could use a table and build out corresponsing columns with the image urls inserted by a conditional column.  The downside to this is I would need to use a table to display the images, along with the blank columns. I was thinking of a conditional column that would build HTML to display the images I could then use an HTML Visualization on the page.  This is where I am hitting a roadblock.  I can't figure out how to append content to a column. Ideally I could have a blank column, and then use condtions to append an image url if Column 1 is TRUE, Column 2 is TRUE, Column 3 is TRUE. etc.

Any ideas on how to build this out and dymaically display images for this use case?

1 ACCEPTED SOLUTION
Amar_Kumar
Continued Contributor
Continued Contributor

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

View solution in original post

4 REPLIES 4

@GeraldGEmerick 

I am tracking some competitions.  The competitions can be a part of one or more competition circuits. The first page lists out the competitions, and some details regarding them.  The drill through page will display a more detailed list of information.


Sample data below:

CompetitionDateCircuit 1Circuit 2Circuit 3Circuit 4
Comp112/1/2025FALSETRUEFALSEFALSE
Comp212/15/2025TRUETRUEFALSEFALSE
Comp312/31/2025FALSETRUETRUETRUE
Comp41/10/2026FALSEFALSETRUETRUE
Comp51/20/2026TRUETRUETRUETRUE

 

Ideally I would like to have a new CircuitImages column that would be be populated will image urls from each of the applicable circuits.  So for Comp1, it would only contain the url for Circuit 2, Comp2 would have the url for Circuit 1 and Circuit 2. 

Amar_Kumar
Continued Contributor
Continued Contributor

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

Thank you @Amar_Kumar This is what I was looking to accomplish.  I wasn't sure exactly the path to take.

GeraldGEmerick
Memorable Member
Memorable Member

@MichaelRensing I feel like you could use a measure for this but I am not sure that I completely understand what you are trying to accomplish. Any chance you could share some sample data and maybe some additional information about what you are trying to achieve?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.