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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Revokez
Frequent Visitor

Filtering by whether Image Exists or Not

Hi

 

I've got a table of data that includes a column that pulls in an image URL using the Data Category: Image URL. However some of these images exist and some of these images don't exist. This means when I pull the data into a visualisation that some images show as broken links and others show the actual image.

 

What I would like to achieve is to filter to rows that only have an image that exists and so exclude those that have a broken link (and so don't show an image).

 

Is there any way to achieve this?

 

Thank you

1 ACCEPTED SOLUTION

Hi @Revokez ,

 

We can add a custom in power query editor to identify if this url is valid:

 

let 
ContentType = Binary.InferContentType(Web.Contents([Address]))[Content.Type],
t = Table.RemoveRowsWithErrors(#table({"Type"} ,{{if Text.Contains(ContentType,"image") then 1 else null}} )),
RemoveNull = Table.SelectRows(t,each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null})))
in
not Table.IsEmpty(RemoveNull)

 

3.PNG

 

Then you can use it in any filter you want.

 

4.PNG

 

If you are using the local file address, try to use the File.Content instead of Web.Content


Best regards,

 

Community Support Team _ Dong Li
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

10 REPLIES 10
Tahreem24
Super User
Super User

Hi @Revokez ,

 

You can simply deselect it from Filter Pane. I tried to replica your scenario and removed the broken icon image using Filter Pane. (Attached screen shot below for your reference)

 

Please give Kudos to this efforts and accept this as a solution if it helps!

icon.JPG

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

@Tahreem24 

 

Thanks - I have tried this however it doesn't work unfortunately due to the large quantity of broken images. Ideally if there was a way to 'group' the broken images and exclude them that way.

 

Example screenshot of the column that shows multiple broken images.

 

ImageURL.png

Hi @Revokez ,

 

I understand you requirement. What I suggest you to deselect the broken image value from Filter Pane. I do also have a multiple broken image and I applied this filter so got what you wanted to achieve. (Screen Shot attached Below)

 

icon.JPG

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Hi @Tahreem24 - I think the difference between my example and yours is that in mine, the broken images are all different URLs and so they don't all group together for filtering. Here's a screenshot of the filtering in my example:

 

ss1.png

Can you share the url of your broken image? If possible so.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Hi @Revokez ,

 

We can add a custom in power query editor to identify if this url is valid:

 

let 
ContentType = Binary.InferContentType(Web.Contents([Address]))[Content.Type],
t = Table.RemoveRowsWithErrors(#table({"Type"} ,{{if Text.Contains(ContentType,"image") then 1 else null}} )),
RemoveNull = Table.SelectRows(t,each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null})))
in
not Table.IsEmpty(RemoveNull)

 

3.PNG

 

Then you can use it in any filter you want.

 

4.PNG

 

If you are using the local file address, try to use the File.Content instead of Web.Content


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for providing a solution for this issue.  I have successfully added the column, but all of my URLs evaluate as false.  Whether the image exists or not.

 

An image that should be false, 

https://interfaceinc.scene7.com/is/image/InterfaceInc/7404004999G35S001_custom_custom-242847-029_va1...

 

An image that should be true,

https://interfaceinc.scene7.com/is/image/InterfaceInc/1151006999G15S001_cubic_area_va1?$160x160$

 

Can you help me figure out what might be wrong with my code.  I used your exact code.  Why isn't it working?

 

Thanks in advance!

@v-lid-msft , that's exactly what I was after - perfect, thank you very much!

@Tahreem24 Unfortunately I can't.

 

However as an example of their format (these aren't actual links):

 

www.domaintestpowerbi.com/sj0661_1.jpg

www.domaintestpowerbi.com/sj0662_1.jpg

www.domaintestpowerbi.com/sj0663_1.jpg

www.domaintestpowerbi.com/sj0664_1.jpg

www.domaintestpowerbi.com/sj0665_1.jpg

 

As an example, sj0665 might have a working image, however the rest could return 404s as the image doesn't exist.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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