Forum Discussion
Dynamic Image Display
- 9 years ago
You could probably do something along the lines of create a measure like:
Lowest = CALCULATE(MIN([Severity]),ALLEXCEPT(Table,Table[Category]))
Then create another measure like:
IsLowest = IF(SUM([Severity])=[Lowest],1,0)
Then drop your IsLowest as a filter on your table visualization of the error code images.
The idea here is that Lowest calculates to the MIN taking into account the Category. The IsLowest will be filtered by the row context of the table so only the lowest will be 1.
Hi,
I stumbled across this post looking for a solution to display images based on a text measure. The proposed solution didn't work for me because I needed a truly dynamic solution (whereas this one was hardcoded on category).
I ended up with creating a work around using R scripts, which I detailed in the following blog post:
Dynamically Changing Shapes in Power BI
I'm not 100% happy with it, because of the dependancy on R. I hope the Power BI team implements more customization options and flexibility for images and shapes, just like in SSRS.
koenverbeeck Nice solution Koen. I'm farely certain I've implemented a flavor of this in the past using the images directly tied to the data set. I don't recall if I used Dynamic Segmentation, but the result is such that depending on the values a different image could be displayed in a card or table. Your solution has a lot more flexibility with the image itself not being constrained by the PBI visual type. Very cool, thanks for sharing.
- SqlJason9 years agoMemorable Member
I think I am missing something here. Can't we just make a measure that returns the correct imageurl based on the condition, and then use it as a visual filter? Eg – http://sqljason.com/2016/04/hex-tile-grid-maps-for-power-bi.html (check out the portion where the images of the president change).
We can create a disconnected table in the Model (just 2 rows with ThumbsUp and ThumbsDown image url and description). Then create a measure which will return 1 for ThumbsUp if the condition is true, 1 for ThumbsDown if it’s condition is true, else 0
Test = SUMX(VALUES(Img[State]), SWITCH(Img[State], “ThumbsUp”, IF(CALCULATE(SUM(Table1[Measure]))>95,1,0), IF(CALCULATE(SUM(Table1[Measure]))>95,0,1)))Now you can just add this measure to the visual filter of the ImageViewer and see that the image changes based on what you select. You can see the result below –
https://jasonsql.files.wordpress.com/2017/02/temp.gifI am trying to undertsand the benefits of the R solution, and I am sure I am missing something. Is the benefit that we don't have to load the ImageURLs/images in Power BI?
- koenverbeeck9 years agoAdvocate II
Hi Jason,
(thanks for your comment on my blog btw).
I couldn't figure out how to pass the filter to the Image Viewer, so that's why I came up with the R solution.
The advantage of the R solution is indeed that you don't have to download the images. The R solution will still work when disconnected.
That being said, I do prefer your solution over mine if there is an Internet connection, as it doesn't rely on an R distribution being present.
- SqlJason9 years agoMemorable Member
Ahhhh, now I get it. I completely forgot about the internet connectivity part :). That is a definite advantage, thanks for explaining it.