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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
monojchakrab
Resolver III
Resolver III

Insert column in Tables, using values from another column

Hiya good people,

 

I am trying to solve, possibly a wierd problem. I have a table as below :

 

monojchakrab_0-1677735251358.png

What I want to do is as follows :

 

In each of the table under the [Data] column, i want to insert a column which will populate the new column with the corresponding name under the column [Account]. E.g. In the 1st table, from the [Data] column, I would like to insert a column, filled with the account name, "JioMart"

 

If I simply use Table.AddColumn, I am getting an error.

 

Is there a way to solve this in power query?

 

Any help much appreciated

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

NewStep=Table.ReplaceValue(PreviousStepName,each [Account],"",(x,y,z)=>Table.AddColumn(x,"Account",each y),{"Data"})

View solution in original post

3 REPLIES 3
monojchakrab
Resolver III
Resolver III

@wdx223_Daniel - That worked like a charm, although I could not understand the logic fully...

E.g. how is the function getting its values for x,y & z?

the 4th parameter of Table.ReplaceValue is a function of Replacer.ReplaceText or Replacer.ReplaceValue

and, about the syntax of those function you can refer to this site.

https://learn.microsoft.com/en-us/powerquery-m/replacer-functions

wdx223_Daniel
Super User
Super User

NewStep=Table.ReplaceValue(PreviousStepName,each [Account],"",(x,y,z)=>Table.AddColumn(x,"Account",each y),{"Data"})

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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