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
Janica123
Helper I
Helper I

Display concatenated distinct values in table

Hi Community, 

 

I have a table instead of having a list of all Study_ID's, I'd like to have them in one row

 

Is that possible in Power BI?

 

Kind Regards

 

 

1 ACCEPTED SOLUTION

Hi @Janica123 ,

You can try to use this DAX to create a new calculated table:

NewTable = 
SUMMARIZE(
    'Table',
    'Table'[Name],
    "Concatenated IDs",
    CONCATENATEX(
        FILTER(
            'Table',
            'Table'[Name] = EARLIER('Table'[Name])
        ),
        'Table'[ID],
        ","
    )
)


The final output is as below:

vjunyantmsft_0-1708588818455.png


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

View solution in original post

4 REPLIES 4
v-junyant-msft
Community Support
Community Support

Hi @Janica123 ,

Here is the sample data:

vjunyantmsft_0-1708565683020.png

Put this M function into Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxPVdJRMjE1MVKK1UFwTQ1QuGbmKFwLS2SumYEBKtdQKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, ID = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type number}}),
    GroupedRows = Table.Group(
        #"Changed Type",
        {"Name"},
        {
            {"All_IDs", each Text.Combine(List.Transform(_[ID], each Text.From(_)), ","), type text}
        }
    )
in
    GroupedRows

The final output is as below:

vjunyantmsft_1-1708565775534.png


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

Thank you very much @v-junyant-msft !

Is there also a way to only do it in DAX?

 

Best regards!

Hi @Janica123 ,

You can try to use this DAX to create a new calculated table:

NewTable = 
SUMMARIZE(
    'Table',
    'Table'[Name],
    "Concatenated IDs",
    CONCATENATEX(
        FILTER(
            'Table',
            'Table'[Name] = EARLIER('Table'[Name])
        ),
        'Table'[ID],
        ","
    )
)


The final output is as below:

vjunyantmsft_0-1708588818455.png


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

zenisekd
Super User
Super User

Hi, I see two ways here.
A) in power query you right-click on the first column and select unpivot other columns and then you merge the other columns with a ", " separator
B) you use Group by and adjust the function to concatenate. https://www.youtube.com/watch?v=eH3ezMimLY0&ab_channel=TechTARSolutions


Kudos and mark as solution appreciated.

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.

Top Solution Authors
Top Kudoed Authors