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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
rphang
Frequent Visitor

CONCATENATE with Condition (To be used in Visuals)

Hi there,

 

Apologies first hand if there's a similar request within the forum.

 

I need some help & advice getting around presenting my data on a donut visual. Not sure by using Measures or adding custom column would be the most ideal solution. Below is the sample Table and the results I want to achieve.

 

Within each of my transactions, there are a few item type and sub-type; "Type A" and "Type B".

 

Table Name: Table X

Transaction No.Type AType B
A0001FragranceSales Product
A0001FragranceSales Product
A0001FragranceSamples
A0001Make-upSamples
A0001Make-upSales Product
A0001FragranceSales Product
A0002Make-upSamples
A0002Make-upSales Product
A0002SkincareSales Product
A0003SkincareSales Product
A0003FragranceSales Product
A0003Make-upSamples
A0003SkincareSales Product
A0004Make-upSales Product
A0004Make-upSamples
A0004Make-upSales Product

 

I would like to have all the "Type A" to be converted into Acronyms (FR / MU / SC) before concatenation, using the delimiter of "&". (Table & Donut visual below)

 

The concatenation does not need to be in a fixed sequence, however, if there's a result of "FR & MU" and " MU & FR", they should be combined as one Category when showing as a donut.

 

However, concatenation should omit criteria "Type B"; Type A that does not belong to "Sales Product".

Transaction No.Type A (Category)
A0001FR & MU
A0002MU & SC
A0003SC & FR
A0004MU

 

rphang_1-1634877224718.png

 

Currently I am using the following DAX measures which takes into account all Type A regardless if it is a Sales Product or Samples.

CALCULATE(CONCATENATEX(VALUES('Table X'[Type A]),'Table X'[Type A]," & "))

 

Thank you in advance!

1 ACCEPTED SOLUTION
Jos_Woolley
Solution Sage
Solution Sage

Ah, for a calculated column use:

NewColumn = CONCATENATEX (
    DISTINCT (
        SELECTCOLUMNS (
            FILTER ( 'Table X', 'Table X'[Type B] = "Sales Product" && 'Table X'[Transaction No.]=EARLIER('Table X'[Transaction No.] )),
            "Type A", 'Table X'[Type A]
        )
    ),
    LOOKUPVALUE (
        'Type A Abbreviations'[Abbreviation],
        'Type A Abbreviations'[Type A], [Type A]
    ),
    " & "
)

Regards

View solution in original post

5 REPLIES 5
Jos_Woolley
Solution Sage
Solution Sage

You're welcome!

 

Cheers

Jos_Woolley
Solution Sage
Solution Sage

Ah, for a calculated column use:

NewColumn = CONCATENATEX (
    DISTINCT (
        SELECTCOLUMNS (
            FILTER ( 'Table X', 'Table X'[Type B] = "Sales Product" && 'Table X'[Transaction No.]=EARLIER('Table X'[Transaction No.] )),
            "Type A", 'Table X'[Type A]
        )
    ),
    LOOKUPVALUE (
        'Type A Abbreviations'[Abbreviation],
        'Type A Abbreviations'[Type A], [Type A]
    ),
    " & "
)

Regards

@Jos_Woolley Perfect! This completely works. Thank you!

Jos_Woolley
Solution Sage
Solution Sage

I'd first create another two-column table to store the Type A abbreviations, named Type A Abbreviations. After which the required measure is:

MyMeasure =
CONCATENATEX (
    DISTINCT (
        SELECTCOLUMNS (
            FILTER ( 'Table X', 'Table X'[Type B] = "Sales Product" ),
            "Type A", 'Table X'[Type A]
        )
    ),
    LOOKUPVALUE (
        'Type A Abbreviations'[Abbreviation],
        'Type A Abbreviations'[Type A], [Type A]
    ),
    " & "
)

Regards

@Jos_Woolley

Thank you, I created a seperated table and relationship between Type A.

rphang_1-1634894197836.png

 

I used your code as "New Column" instead of Dax measures since I want to use it under Legend within the donut visual. But I am getting "FR & MU & SC" for all transaction.

rphang_0-1634894105282.png

Can I check what modification needs to be done to the coding? Or I place the code on the wrong table?

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.