Forum Discussion
filtering and saving into new column
- 4 years ago
You will need to remove complete Source line in my code and replace that with your source line. _t are generated when you use PQ's Enter Data feature to generate data rather than pulling from a source.
Use the below new code for your task
let Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content], BuffList1 = List.Buffer(Source[Column1]), BuffList2 = List.Buffer(List.RemoveNulls(List.ReplaceValue(Source[Column2],"",null,Replacer.ReplaceValue))), BuffList1Count = List.Count(BuffList1), GenList = List.Generate(()=>[x=Text.Combine(List.Select(BuffList2,(a)=>List.Contains(Text.Split(BuffList1{0}," "),a, Comparer.OrdinalIgnoreCase)),", "),i=0], each [i]<BuffList1Count, each [i=[i]+1, x=Text.Combine(List.Select(BuffList2,(a)=>List.Contains(Text.Split(BuffList1{i}," "),a, Comparer.OrdinalIgnoreCase)),", ")], each [x]), Result = Table.FromColumns(Table.ToColumns(Source)&{GenList},Table.ColumnNames(Source)&{"Result"}) in Result
this is running endless col1 has 18k rows and col2 has 3k,
it loaded like 2.9L with over 2.5Lac errors
Since you have this in Excel, is it possible for you to share your workbook alongwith data and query?
- Vijay_A_Verma4 years agoMost Valuable Professional
You will need to remove complete Source line in my code and replace that with your source line. _t are generated when you use PQ's Enter Data feature to generate data rather than pulling from a source.
Use the below new code for your task
let Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content], BuffList1 = List.Buffer(Source[Column1]), BuffList2 = List.Buffer(List.RemoveNulls(List.ReplaceValue(Source[Column2],"",null,Replacer.ReplaceValue))), BuffList1Count = List.Count(BuffList1), GenList = List.Generate(()=>[x=Text.Combine(List.Select(BuffList2,(a)=>List.Contains(Text.Split(BuffList1{0}," "),a, Comparer.OrdinalIgnoreCase)),", "),i=0], each [i]<BuffList1Count, each [i=[i]+1, x=Text.Combine(List.Select(BuffList2,(a)=>List.Contains(Text.Split(BuffList1{i}," "),a, Comparer.OrdinalIgnoreCase)),", ")], each [x]), Result = Table.FromColumns(Table.ToColumns(Source)&{GenList},Table.ColumnNames(Source)&{"Result"}) in Result - Anonymous4 years agoNot applicable
HAPPY 75th India Independence Day to all
It worked it was my mistake i was referencing data on which i already performed another query. - Vijay_A_Verma4 years agoMost Valuable Professional
Use this
let Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content], CharsList = {"A".."Z","a".."z"," "}, BuffList1 = List.Buffer(Source[Column1]), BuffList2 = List.Buffer(List.RemoveNulls(List.ReplaceValue(Source[Column2],"",null,Replacer.ReplaceValue))), BuffList1Count = List.Count(BuffList1), GenList = List.Generate(()=>[x=Text.Combine(List.Select(BuffList2,(a)=>List.Contains(Text.Split(Text.Select(BuffList1{0},CharsList)," "),a, Comparer.OrdinalIgnoreCase)),", "),i=0], each [i]<BuffList1Count, each [i=[i]+1, x=Text.Combine(List.Select(BuffList2,(a)=>List.Contains(Text.Split(Text.Select(BuffList1{i},CharsList)," "),a, Comparer.OrdinalIgnoreCase)),", ")], each [x]), Result = Table.FromColumns(Table.ToColumns(Source)&{GenList},Table.ColumnNames(Source)&{"Result"}) in Result - Anonymous4 years agoNot applicable
i am sorry working on company confidential data
i can complete this in java easy peasy but they have restricted me to query have to learn from scratch.
In second solution you removed let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t])
what does this line do?
after giving the desired output it is running endless loop
for big data take any string dump in coltake half dictonary in col 2 and try
i just copy pasted thislet Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}), #"Replaced Value" = Table.ReplaceValue(#"Changed Type","",null,Replacer.ReplaceValue,{"Column2"}), BuffList = List.Buffer(List.RemoveNulls(#"Replaced Value"[Column2])), #"Added Custom1" = Table.AddColumn(#"Replaced Value", "Result", each Text.Combine(List.Intersect({BuffList,Text.Split([Column1]," ")},Comparer.OrdinalIgnoreCase)," ")) in #"Added Custom1" - Anonymous4 years agoNot applicable
col 1 has 18438 col2 has 3567
while selcting table i have selected these only, they dont have blanks or nulls.but after showing correct output in query editior when i close and load it doesnt stop running
i just copy pasted the entire code changed table number - Anonymous4 years agoNot applicable
Another issue
it is skipping words like which are enclosed with doublequotes
example
"Demo
Insert/demo
if i try to remove all special character from the column and replace them with space
then words like can't converts into can t then t gets skip
- Vijay_A_Verma4 years agoMost Valuable Professional
I need to see few samples for column1 and column2 containing these kind of words...
- Anonymous4 years agoNot applicable
- Anonymous4 years agoNot applicable