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

Concatenate Values of the same Column

Hi, 

 

I have been trying to solve this issue for a couple of hours and thought my best bet would be to contact the community for some help. I am using a dataset which has 2 important values that should essentially be in separate columns. I have created a dataset below to give an idea of what I am trying to achieve:

 

ResourceSkill/Type
<none>E10641067
Joe BloggsGRADE 5_LCL
Joe JonesGRADE 5_TRA
<none>E20612947
Sam BlueGRADE 5_LCL
Sam BlueGRADE 5_TRA

 

I basically need to concatenate the "E" numbers to the beginning of the GRADE so that I can filter them out in a report.

 

It sounds logically impossible in my head - however I am quite unfamiliar with power query so who knows.

 

Any help would be appreciated.

2 ACCEPTED SOLUTIONS
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOzsvPSwWzUpV0lFwNDcxMgNhcKVYnWskrP1XBKSc/Pb0YKOUe5OjiqmAa7+PsA5f0AupFlgsJcgTLYTPZyMDM0MjSBGJycGIu0OTSVCzmYpECGxsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Resource = _t, #"Skill/Type" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.Start([#"Skill/Type"],1)="E" and [Resource]="<none>" then Text.Middle([#"Skill/Type"],1) else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}),
    #"Added Custom1" = Table.AddColumn(#"Filled Down", "Final Skill/Type", each if Text.Start([#"Skill/Type"],1)="E" and [Resource]="<none>" then [#"Skill/Type"] else [Custom]&[#"Skill/Type"]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Skill/Type", "Custom"})
in
    #"Removed Columns"

 

View solution in original post

Use below query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOzsvPSwWzUpV0lFwNDcxMgNhcKVYnWskrP1XBKSc/Pb0YKOUe5OjiqmAa7+PsA5f0AupFlgsJcgTLYTPZyMDM0MjSBGJycGIu0OTSVCzmYpECGxsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Resource = _t, #"Skill/Type" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "SkillTemp", each if not (Text.Start([#"Skill/Type"],5)="GRADE") then [#"Skill/Type"] else null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Type", each if Text.Start([#"Skill/Type"],5)="GRADE" then [#"Skill/Type"] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom1",{"SkillTemp"}),
    #"Added Custom2" = Table.AddColumn(#"Filled Down", "Skill", each if [Resource]="<none>" then null else [SkillTemp]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Skill/Type", "SkillTemp"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Resource", "Skill", "Type"})
in
    #"Reordered Columns"

View solution in original post

5 REPLIES 5
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOzsvPSwWzUpV0lFwNDcxMgNhcKVYnWskrP1XBKSc/Pb0YKOUe5OjiqmAa7+PsA5f0AupFlgsJcgTLYTPZyMDM0MjSBGJycGIu0OTSVCzmYpECGxsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Resource = _t, #"Skill/Type" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.Start([#"Skill/Type"],1)="E" and [Resource]="<none>" then Text.Middle([#"Skill/Type"],1) else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}),
    #"Added Custom1" = Table.AddColumn(#"Filled Down", "Final Skill/Type", each if Text.Start([#"Skill/Type"],1)="E" and [Resource]="<none>" then [#"Skill/Type"] else [Custom]&[#"Skill/Type"]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Skill/Type", "Custom"})
in
    #"Removed Columns"

 

Hi @Vijay_A_Verma ,

 

I tried your solution. It is similar to the expected outcome. However, might I add that the "E" numbers (including the "E") will need to be in a separate column before the "GRADE".

 

Kind Regards

 

Can you please post the expected output table / picture?

Hi @Vijay_A_Verma ,

 

Below is an expected outcome from the query.

 

Cheers 

ResourceSkillType
<none>  
Joe BloggsE10641067GRADE 5_LCL
Joe JonesE10641067GRADE 5_TRA
<none>  
Sam BlueE20612947GRADE 5_LCL
Sam BlueE20612947GRADE 5_TRA

 

Use below query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBOzsvPSwWzUpV0lFwNDcxMgNhcKVYnWskrP1XBKSc/Pb0YKOUe5OjiqmAa7+PsA5f0AupFlgsJcgTLYTPZyMDM0MjSBGJycGIu0OTSVCzmYpECGxsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Resource = _t, #"Skill/Type" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "SkillTemp", each if not (Text.Start([#"Skill/Type"],5)="GRADE") then [#"Skill/Type"] else null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Type", each if Text.Start([#"Skill/Type"],5)="GRADE" then [#"Skill/Type"] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom1",{"SkillTemp"}),
    #"Added Custom2" = Table.AddColumn(#"Filled Down", "Skill", each if [Resource]="<none>" then null else [SkillTemp]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Skill/Type", "SkillTemp"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Resource", "Skill", "Type"})
in
    #"Reordered Columns"

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