Forum Discussion

JS0309's avatar
JS0309
Frequent Visitor
1 year ago
Solved

base64 Dynamic Image URL

Hello,

 

I have 3 measures that embed base64 strings to display images. 

Green Check = 

"data:image/png;base64xxxxxxx"
Red X = 
"data:image/png;base64yyyyyyy"

Yellow Warning = 

"data:image/png;base64zzzzzz"

 

I want to use those 3 images dynamically in a card visual so I created the following

 

ImageD = 
VAR Green Check = [green check]

VAR Red X = [Red X]

VAR Yellow Warning = [Yellow Warning]

 

 
RETURN
SWITCH(TRUE(),
    [profit] > 0, Green Check ,
    [profit] <= 0, Red X,
    Yellow Warning
)
 

 

When I tried to use the imageD measure as an image url in a card visual, Power BI does not let me click on the OK button. Howerver, if I get rid of the variables in ImageD measure and just embed the base64 strings in the SWITCH condition then it works. I tried changing the categories of the measures but no luck. It seems Power BI does not regonize the measure as a string and does not let me use it when I use variables pointing back to the 3 original measures. Do you know how to fix it? I also want to use these images for other metrics.

 

Thank you

6 Replies

  • JS0309 , Try creating separate measures for each image:

    GreenCheckImage = "data&colon;image/png;base64xxxxxxx"
    RedXImage = "data&colon;image/png;base64yyyyyyy"
    YellowWarningImage = "data&colon;image/png;base64zzzzzz"

     

    Use these measures in your ImageD measure:

    DAX
    ImageD =
    SWITCH(TRUE(),
    [profit] > 0, [GreenCheckImage],
    [profit] <= 0, [RedXImage],
    [YellowWarningImage]
    )

  • v-nmadadi-msft's avatar
    v-nmadadi-msft
    Community Support

    Hi JS0309,

    May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

    Thank you.

  • v-nmadadi-msft's avatar
    v-nmadadi-msft
    Community Support

    Hi JS0309 ,

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If our responses has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


    Thank you.

  • v-nmadadi-msft's avatar
    v-nmadadi-msft
    Community Support

    Hi JS0309 ,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the community members for the issue worked. If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Thanks and regards