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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Michal_Plawski
Regular Visitor

Custom Icons within Dax Measure returning Text.

Hi,

I am working on a report for accessing information about uploaded documents (via MS Forms).
I created a measure, that depending on the row level, will either give us the name of the file with a conditional icon (they are added to the json theme) that reflects that file's extension, or a Sharepoint Icon, and a count of different files + Count of file types.

This is the measure:

Document Title* =
VAR _List = CALCULATE(CONCATENATEX(DISTINCT('fact_OfficeForms Table'[Extension]), 'fact_OfficeForms Table'[Extension],", "))
VAR _FileTypeCount = DISTINCTCOUNTNOBLANK('fact_OfficeForms Table'[Extension])

VAR _Result =
IF(
    HASONEVALUE('fact_OfficeForms Table'[ID]),
    SELECTEDVALUE('fact_OfficeForms Table'[Document Title]),
    IF(
        COUNT('fact_OfficeForms Table'[ID])=0,
        BLANK(),
        DISTINCTCOUNTNOBLANK('fact_OfficeForms Table'[ID])&" documents uploaded. "& _FileTypeCount& " file type(s) : " & _List
    )
)
RETURN
_Result

 

Michal_Plawski_0-1712656982785.png

 

In the case where there are multiple files in the row level context, instead of simply listing the file type extensions I would like to list the icons, like this:

Michal_Plawski_1-1712657699352.png

But I don't know if it is possible to use Icons that way, in text (not in conditional formatting).

Any help would be much appreciated!

Best regards,
Mike.


 

 

3 REPLIES 3
johnbasha33
Solution Sage
Solution Sage

@Michal_Plawski 
Here's how you can modify your measure to include icons alongside the file extensions:

Document Title* =
VAR _List = CONCATENATEX(
DISTINCT('fact_OfficeForms Table'[Extension]),
"<img src='" &
SWITCH(
'fact_OfficeForms Table'[Extension],
"pdf", "path_to_pdf_icon",
"docx", "path_to_docx_icon",
"xlsx", "path_to_xlsx_icon",
"path_to_default_icon"
)
& "' title='" & 'fact_OfficeForms Table'[Extension] & "'/>",
", "
)
VAR _FileTypeCount = DISTINCTCOUNTNOBLANK('fact_OfficeForms Table'[Extension])

VAR _Result =
IF(
HASONEVALUE('fact_OfficeForms Table'[ID]),
SELECTEDVALUE('fact_OfficeForms Table'[Document Title]),
IF(
COUNT('fact_OfficeForms Table'[ID]) = 0,
BLANK(),
DISTINCTCOUNTNOBLANK('fact_OfficeForms Table'[ID]) & " documents uploaded. " & _FileTypeCount & " file type(s) : " & _List
)
)
RETURN
_Result

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

v-yangliu-msft
Community Support
Community Support

Hi  @Michal_Plawski ,

 

This is the related document, you can view this content:

Tips on displaying icons based on field values in ... - Microsoft Fabric Community

End-to-End Example for Adding Icons to Your Power ... - Microsoft Fabric Community

How to use custom icons in DAX - Microsoft Fabric Community

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yangliu-msft,

Unfortunatelly, this is a way to use custom icons as conditional formatting, and I was able to do that already.
I am looking for a way, to use them as part of a text measure, where I could use multiple icons interweaved with text in a single table cell, or in a card visual.
I will mention that using char(s) is not the answer I am looking for either, as I am looking for flexibility in terms of the icons I am able to use.

Best regards,
Mike

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.