Forum Discussion
Nooby
6 years agoHelper I
Fetching a column values from another column
Hello everyone, I have a column which has the values such as: CODE COLUMN XXYYZZTT PPRRQQSS .. .. .. And there is another column in another table DIRTY DATA 1...
- 6 years ago
Hi,
Please try this in Query Editor:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NYo7DoAgEETvQm3DLol6C34FQihIFnqxwOOLKJPXzMwLgXHAjnPH4b21X+uwuAQ2VyEA8H5TqOVxUaKSW811Ovu2jiNdVBBEyvX8xYIogHd/dC6l1koZU4GAxfgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"DIRTY DATA" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"DIRTY DATA", type text}}), KeyWordTable = Table.Buffer(#"Table 1"), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let t = [DIRTY DATA] in Table.SelectRows(Table.AddColumn(KeyWordTable,"New",each Text.Replace(t,[CODE COLUMN],"#(lf)")),each Text.Contains(t,[CODE COLUMN]))), #"Added Custom 2" = Table.AddColumn(#"Added Custom", "Custom2", each Table.ReorderColumns(Table.RenameColumns(Table.RemoveColumns(Table.AddColumn(Table.AddColumn(Table.SplitColumn([Custom], "New", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"New.1", "New.2"}), "fetched column1", each Text.End([New.1],1)), "fetched column3", each Text.Start([New.2],3)),{"New.1", "New.2"}),{{"CODE COLUMN", "fetched column2"}}),{"fetched column1", "fetched column2", "fetched column3"})), #"Removed Columns" = Table.RemoveColumns(#"Added Custom 2",{"Custom"}), #"Expanded Custom2" = Table.ExpandTableColumn(#"Removed Columns", "Custom2", {"fetched column1", "fetched column2", "fetched column3"}, {"Custom2.fetched column1", "Custom2.fetched column2", "Custom2.fetched column3"}), #"Renamed Columns" = Table.RenameColumns(#"Expanded Custom2",{{"Custom2.fetched column1", "fetched column1"}, {"Custom2.fetched column2", "fetched column2"}, {"Custom2.fetched column3", "fetched column3"}}), #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns",{"DIRTY DATA"}), #"Replaced Value" = Table.ReplaceValue(#"Removed Columns1","",null,Replacer.ReplaceValue,{"fetched column1","fetched column2","fetched column3"}) in #"Replaced Value"The result shows:
Here is my test pbix:
Hope this can help.
Best Regards,
Giotto Zhi
Nooby
6 years agoHelper I
Ashish_Mathur , thank you very much for your time.
I just copied "Fetched column2" as you suggested and pasted, nothing happens.
What am I doing wrong here?
Ashish_Mathur
6 years agoSuper User
Hi,
Mine is a DAX formula so write it as a calculated column formula.
- Nooby6 years agoHelper I
Thank you very much Ashish_Mathur ,
It worked on report view like a charm.
But I cannot see that columns on "Power Query Editor". Is there a trick to use them there?
- Ashish_Mathur6 years agoSuper User
Hi,
I do not know how to solve this problem in the Query Editor.