Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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
)
Solved! Go to 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
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.
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
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
112 | |
107 | |
97 | |
39 | |
32 |
User | Count |
---|---|
153 | |
122 | |
77 | |
74 | |
44 |