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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
bonjourposte
Helper V
Helper V

Which function do I use for this? (instead of SWITCH)

Having a brain fart.  I've got hundreds of images I can bring into my Power BI reports via Sharepoint, and Bas has a good youtube video for how to do this, but only in a measure where he uses the Switch function.  (He says this can also work in a column, but it didn't work for me, so I'm going back to a measure.)

 

He uses the SWITCH function:

 

Image Product Category = 

SWITCH(

    MAX(dimProduct[ProductCategoryName]),

    "Audio", "Image1",

    "Computers", "Image2",

    "Cell Phones", "Image3"

)

 

...but I don't want to list every single instance and then its URL.  I'm using loan numbers and pictures of their collateral.  I just want to say "when you see this loan number, post its respective image."  What is the syntax for that?

 

Thanks.

 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @bonjourposte -You're on the right track with using the SWITCH function, but as you've noticed, manually listing every image URL for each loan number can get cumbersome, especially with hundreds of images. Instead, you can simplify this by creating a relationship between your loan numbers and their respective image URLs in a table, and then use a measure to dynamically return the image URL based on the loan number.

 

You can create a measure using CONCATENATE (or &) to build the full image URL dynamically from the loan number:

LoanImageURL =
VAR LoanNumber = MAX(LoanData[LoanNumber]) -- Get the current loan number
RETURN
"https://yoursharepointsite/images/" & LoanNumber & ".jpg" -- Construct the URL dynamically

 

You don’t need to create a separate table with loan numbers and URLs. Hope this works in your case.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
rajendraongole1
Super User
Super User

Hi @bonjourposte -You're on the right track with using the SWITCH function, but as you've noticed, manually listing every image URL for each loan number can get cumbersome, especially with hundreds of images. Instead, you can simplify this by creating a relationship between your loan numbers and their respective image URLs in a table, and then use a measure to dynamically return the image URL based on the loan number.

 

You can create a measure using CONCATENATE (or &) to build the full image URL dynamically from the loan number:

LoanImageURL =
VAR LoanNumber = MAX(LoanData[LoanNumber]) -- Get the current loan number
RETURN
"https://yoursharepointsite/images/" & LoanNumber & ".jpg" -- Construct the URL dynamically

 

You don’t need to create a separate table with loan numbers and URLs. Hope this works in your case.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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