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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Jeffreyjar
Helper II
Helper II

link two columns with powerquery with condition

Hello, i have an issue, i want to link column EEAGENT with column EAFCR but with one specification like 

- Fill empty  rows from EAAGENT to EAFCR (with power query) 

 

EEAGENT          EAFCR
A10399028        A10399026
A10399029        A10399027
A10199002 
A10199003 

 

Kind Regards         

 

@rsbin                     

@ryan_mayu 

@AlexisOlson 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Select one of the empty cells and click Transform > Replace Values. This should open up a box where you can specify what to replace. Leave the first box empty and put something in the second box.

AlexisOlson_0-1665071565375.png

This should generate a step like

= Table.ReplaceValue(Source,"","placeholder",Replacer.ReplaceValue,{"EAFCR"})

Now all we need to do is tweak the generated code to replace the placeholder with "each [EEAGENT]":

= Table.ReplaceValue(Source,"",each [EEAGENT],Replacer.ReplaceValue,{"EAFCR"})

Result:

AlexisOlson_1-1665071686503.png

 

Full sample code you can paste into the Advanced Editor of a new blank query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjQ0MLa0NDCyUNKBs82UYnUQMpZIMuYwGUMgz8AIKIMiYAwWiAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [EEAGENT = _t, EAFCR = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"",each [EEAGENT],Replacer.ReplaceValue,{"EAFCR"})
in
    #"Replaced Value"

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

Select one of the empty cells and click Transform > Replace Values. This should open up a box where you can specify what to replace. Leave the first box empty and put something in the second box.

AlexisOlson_0-1665071565375.png

This should generate a step like

= Table.ReplaceValue(Source,"","placeholder",Replacer.ReplaceValue,{"EAFCR"})

Now all we need to do is tweak the generated code to replace the placeholder with "each [EEAGENT]":

= Table.ReplaceValue(Source,"",each [EEAGENT],Replacer.ReplaceValue,{"EAFCR"})

Result:

AlexisOlson_1-1665071686503.png

 

Full sample code you can paste into the Advanced Editor of a new blank query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjQ0MLa0NDCyUNKBs82UYnUQMpZIMuYwGUMgz8AIKIMiYAwWiAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [EEAGENT = _t, EAFCR = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,"",each [EEAGENT],Replacer.ReplaceValue,{"EAFCR"})
in
    #"Replaced Value"

thanks it works

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