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
hcdecon
Regular Visitor

SWITCH function to use images in Slicer

Hello. 

 

I am trying to use the SWITCH function to replace text for images in a Slicer but for some reason it's not working. The image URLs are fine, I think it may be because the table has active relationships with other tables but not sure how to combat this.

Untitled.png

 

I can't use a Chiclet slicer because this does not sync across the whole report.

 

Any help would be appreciated, thanks!

8 REPLIES 8
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @hcdecon,

 

From the screenshot, it seems that you have some mistakes for the switch formula which I highlight in red.

 

Untitled.png

 

Please modify your formula and try again.

 

If you still need help, could you please share a dummy pbix file which can reproduce the scenario, so that we can help further investigate on it? You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.)

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-piga-msft thanks for the response. 

 

I removed the comma but then the error message "DAX comparison operations do not support comparing values of type Text with values of type Number. Consider using the VALUE or FORMAT function to convert one of the values." came up? The expressions (18-35 etc) are categories of ages. 

Anonymous
Not applicable

Adding to @v-piga-msft response, a switch statement also needs an 'other' value.  Effectively this is what the switch statement needs to do if all of the conditions fail.  so rather than remove the Comma as has been suggested, you need an image url to show if none of the above conditions are satisfied..

Hi @Anonymous thanks for the response. 

 

Sorry I'm quite new to this, how do I add the 'other' value to show if none of the above conditions are satisfied? I couldn't find the answer online.

Hi  @hcdecon,

 

Have you solved your problem?

 

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

If you still need help, please feel free to ask.

 

Best Regagrds,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Cherry, 

 

That problem is solved - I just created a seperate column for ID and used that instead. However, the actual image won't show up on the filter, just the image URL. I have tried several URLS with the same result.  Here is a link to a dummy version of the file: https://app.box.com/s/eouqtyk37ipoainxg6xoyms2q9ybff15 

 

Thanks, any help would be appreciated. 

Hi @hcdecon,

 

Please change the Date category of the image url measure to be image URL.

 

image url.PNG

 

In addtion, images work for URL that over web not local path in Power BI Desktop.

 

Best Regards,

Cherry

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

Switch Statements are normally written like this:

SWITCH(
	"Compare to me",
	"Are you 6?", "This is the answer",
	"Are you 7?", "That is the answer",
	"Are you more than 7?", "Answer this way",
	"Instead answer like this"
)

Or sometimes in a format more like this

SWITCH(
	TRUE,
	6 = 'Table'[Field], "This is the answer",
	7 = 'Table'[Field], "That is the answer",
	'Table'[Field] > 7, "Answer this way",
	"Instead answer like this"
)

Hopefully this illustrates it better for you

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.