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
GB2020
New Member

concatenatex help needed to

Hello,

 

From what I understand, I need to use concatenatex per https://www.purplefrogsystems.com/blog/2020/06/using-concatenatex-in-powerbi-to-return-multiple-valu... however not sure how to apply in this example. Need to list all unique SubitemID's where "Name" has same "Item".

 

* SubitemID is unique to Name

 

Here is an example table and DESIRED result is in "List of SubitemID". 

 

NameItemSubitemIDList of SubitemID
hunting392156 
hunting396859 
hunting39756159,56
hunting39755961, 56
hunting39755661,59
hunting397856 
hunting398256 
hunting403859 
hunting404356 
hunting405156 
hunting406459 
fishing40726159,56
fishing40725961,56
fishing40725661,59
camping33994071,72,73
camping33997140,72,73
camping33997240,71,73
camping33997340,71,72
camping404371 

 

Thank you!

2 ACCEPTED SOLUTIONS
AlB
Super User
Super User

Hi @GB2020 

If it's a calculated column that you're after, as it seems from your expected result:

 

List of SubitemID =
VAR auxT_ =
    CALCULATETABLE (
        DISTINCT ( Table1[SubitemID] ),
        ALLEXCEPT ( Table1, Table1[Name], Table1[Item] ),
        Table1[SubitemID] <> EARLIER ( Table1[SubitemID] )
    )
RETURN
    CONCATENATEX ( auxT_, Table1[SubitemID], ", " )

 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

CNENFRNL
Community Champion
Community Champion

Hi, @GB2020 , in addition to @AlB 's calculated column solution, here are measure solution and Power Query solution at your disposal,

 

SubitemID List = 
CONCATENATEX (
    FILTER (
        CALCULATETABLE ( 'Table', ALL ( 'Table'[SubitemID] ) ),
        'Table'[SubitemID] <> MAX ( 'Table'[SubitemID] )
    ),
    [SubitemID],
    ","
) & ""

Screenshot 2020-11-11 013730.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc/LCoAgEAXQf3HdQp3x9S3iIoIeiyKo/j8NQ8pxNXDmcpnxns3Xdi7bxDoGToo4lGah+7q2yV3lRsWhBe2tPNFvLO1WUo4cyHuQI9B5Rf6FXGPpGZdjft3I8lflrXzuH/p1z/eDc8+adiMaLhsOP8//pp5wAw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Item = _t, SubitemID = _t]),
    #"Added Custom" = Table.AddColumn(Source, "List of SubitemID",
        each 
            [
                IDlist = Table.Group(Source, {"Name","Item"}, {{"Grouped", each _}}){[Name=[Name], Item=[Item]]}[Grouped][SubitemID],
                result = List.RemoveItems(IDlist, {[SubitemID]})
            ][result]
    ),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"List of SubitemID", each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    #"Extracted Values"

Screenshot 2020-11-11 013804.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
GB2020
New Member

Thank you very much for all the answers; both worked great!

CNENFRNL
Community Champion
Community Champion

Hi, @GB2020 , in addition to @AlB 's calculated column solution, here are measure solution and Power Query solution at your disposal,

 

SubitemID List = 
CONCATENATEX (
    FILTER (
        CALCULATETABLE ( 'Table', ALL ( 'Table'[SubitemID] ) ),
        'Table'[SubitemID] <> MAX ( 'Table'[SubitemID] )
    ),
    [SubitemID],
    ","
) & ""

Screenshot 2020-11-11 013730.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc/LCoAgEAXQf3HdQp3x9S3iIoIeiyKo/j8NQ8pxNXDmcpnxns3Xdi7bxDoGToo4lGah+7q2yV3lRsWhBe2tPNFvLO1WUo4cyHuQI9B5Rf6FXGPpGZdjft3I8lflrXzuH/p1z/eDc8+adiMaLhsOP8//pp5wAw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Item = _t, SubitemID = _t]),
    #"Added Custom" = Table.AddColumn(Source, "List of SubitemID",
        each 
            [
                IDlist = Table.Group(Source, {"Name","Item"}, {{"Grouped", each _}}){[Name=[Name], Item=[Item]]}[Grouped][SubitemID],
                result = List.RemoveItems(IDlist, {[SubitemID]})
            ][result]
    ),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"List of SubitemID", each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    #"Extracted Values"

Screenshot 2020-11-11 013804.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

AlB
Super User
Super User

Hi @GB2020 

If it's a calculated column that you're after, as it seems from your expected result:

 

List of SubitemID =
VAR auxT_ =
    CALCULATETABLE (
        DISTINCT ( Table1[SubitemID] ),
        ALLEXCEPT ( Table1, Table1[Name], Table1[Item] ),
        Table1[SubitemID] <> EARLIER ( Table1[SubitemID] )
    )
RETURN
    CONCATENATEX ( auxT_, Table1[SubitemID], ", " )

 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

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