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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
mark_endicott
Super User
Super User

DAX to test if an Image is returned from URL

Hello, 

 

I am using DAX to construct an Image URL based on selections the user makes in a dashboard. Does anyone know if there is a way of testing if the image exists through DAX? So that if an image does not exist, I can default to another URL.

 

I have tried wrapping an IF ( ISBLANK ( )) around the return of the URL - but ofcourse this is assessing the URL which wont be blank. 

 

Please see below for the full DAX.

 

 

VAR CDN_domain = "anon_domain_name"
VAR current_territory =
    LOWER ( SELECTEDVALUE ( 'TERRITORY'[ISO Currency code] ) )
VAR current_value =
    SELECTEDVALUE ( PRODUCT_ATTRIBUTES[value] )
VAR sas_key =
    CALCULATE (
        SELECTEDVALUE ( 'rls keys'[keyvalue] ),
        KEEPFILTERS (
            FILTER (
                ALL ( 'rls keys'[keyname], 'rls keys'[environment] ),
                'rls keys'[keyname] = "SAS key for images"
                    && 'rls keys'[environment] = "Prod"
            )
        )
    )
VAR full_string = CDN_domain & current_territory & "/" & current_value & ".jpg" & sas_key
RETURN
    IF (
        ISBLANK ( full_string ),
        CDN_domain & "gbr" & "/" & current_value & ".jpg" & sas_key,
        full_string
    )

 

1 ACCEPTED SOLUTION

Hi @mark_endicott ,

 

I'm sorry to say that in DAX, isblank is the most appropriate function to use to determine if a value exists. If you are involved in fewer URLs, perhaps you could write something separately like :

 

If(selecvalue(your url)= true url,"have image","no image")

 

 

Through this to check if your url is right, because right url can return image, so this way is equivalent to an indirect determination, but is more suitable for cases with less data.

For more information about DAX you can refer this link:DAX function reference - DAX | Microsoft Docs

 

Best regards,

Community Support Team Selina zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
v-mengzhu-msft
Community Support
Community Support

Hi @mark_endicott ,

 

Based on my understanding of the concept of the DAX function, I don't actually think you can use it to determine the presence of an image.

vmengzhumsft_0-1661740033039.png

As the documentation says, it is a calculation of the data, so you can determine whether the URL exists, as you say, but not directly whether it can return the image.

 

This is my understanding, please let me know if there is any misunderstanding.

 

Best regards,

Community Support Team Selina zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-mengzhu-msft - So as I am creating the URL with my DAX, is there any way you can think of other than ISBLANK() to qualify if the URL truely exists?

Hi @mark_endicott ,

 

I'm sorry to say that in DAX, isblank is the most appropriate function to use to determine if a value exists. If you are involved in fewer URLs, perhaps you could write something separately like :

 

If(selecvalue(your url)= true url,"have image","no image")

 

 

Through this to check if your url is right, because right url can return image, so this way is equivalent to an indirect determination, but is more suitable for cases with less data.

For more information about DAX you can refer this link:DAX function reference - DAX | Microsoft Docs

 

Best regards,

Community Support Team Selina zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.