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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
bonjourposte
Advocate III
Advocate III

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.