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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Luke__
New Member

Returning names on concatenated text

Hello, 
I've been struggling to find the solution on this Power Query problem for awhile. Hopefully, someone might be able to help me.
As shown below, I have two queries; Rule List and Rule Performance. 
-Rule List itemizes each rule number and displays the name of the rule.
-Rule Performance indicates which rule has fired.

What I'm trying to do is merge the queries together, by matching the concatenated numbers from Rule Performance to the Rule List, and return the names of each rule as a concatenated text.

Example: Second column on rule performance would read as
Names Fired row 1: A, B, C, D, E
Names Fired row 2: E, D, C
Names Fired row 3: B, E, A


Any ideas how I might go about this?

Luke___0-1709957697284.png

Luke___1-1709957714910.png

 

 

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @Luke__, you can find similar code to @Vijay_A_Verma here:

 

@Vijay_A_Verma, it should be otherwise null because if you have otherwise "" then it will include that blank to Names Fired

dufoq3_1-1709981783407.png

 

Result

dufoq3_2-1709981829811.png

 

Just replace RuleTable code with your rule table refenrece and Source code with your table reference (where you have Rules Fired column)

let
    RuleTable = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Hce3DQAwDAOwXzR7SC9j2hWG/38jhrhRFTHlUhsECyYKrns3yw3vYbnpvSwXvA9mHw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Rule Number" = _t, #"Rule Name" = _t]),
    ChangedType = Table.TransformColumnTypes(RuleTable,{{"Rule Number", Int64.Type}}),
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjE101EAU+Y6CmDKQkcBTFnqKIApA6VYnWglCBMhBVEKloLphimBmKoUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Rules Fired" = _t]),
    Ad_NamesFired = Table.AddColumn(Source, "Names Fired", each 
       Text.Combine(List.Transform(Text.Split([Rules Fired], ","), (x)=> try ChangedType{[Rule Number = Number.From(Text.Trim(x))]}[Rule Name] otherwise ""), ", ")
       , type text)
in
    Ad_NamesFired

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

2 REPLIES 2
dufoq3
Super User
Super User

Hi @Luke__, you can find similar code to @Vijay_A_Verma here:

 

@Vijay_A_Verma, it should be otherwise null because if you have otherwise "" then it will include that blank to Names Fired

dufoq3_1-1709981783407.png

 

Result

dufoq3_2-1709981829811.png

 

Just replace RuleTable code with your rule table refenrece and Source code with your table reference (where you have Rules Fired column)

let
    RuleTable = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Hce3DQAwDAOwXzR7SC9j2hWG/38jhrhRFTHlUhsECyYKrns3yw3vYbnpvSwXvA9mHw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Rule Number" = _t, #"Rule Name" = _t]),
    ChangedType = Table.TransformColumnTypes(RuleTable,{{"Rule Number", Int64.Type}}),
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjE101EAU+Y6CmDKQkcBTFnqKIApA6VYnWglCBMhBVEKloLphimBmKoUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Rules Fired" = _t]),
    Ad_NamesFired = Table.AddColumn(Source, "Names Fired", each 
       Text.Combine(List.Transform(Text.Split([Rules Fired], ","), (x)=> try ChangedType{[Rule Number = Number.From(Text.Trim(x))]}[Rule Name] otherwise ""), ", ")
       , type text)
in
    Ad_NamesFired

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Vijay_A_Verma
Super User
Super User

Insert a custom column named Names Fired and put below formula in that

Text.Combine(List.Transform(Text.Split([Rules Fired], ","), (x)=> try #"Rule List"{[Rule Number = x]}[Rule Name] otherwise ""), ",")

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors