Forum Discussion

bonjourposte's avatar
bonjourposte
Helper V
1 year ago
Solved

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.

 

  • 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.