Forum Discussion
Help required to separate the text
There is nothing like that in sample data. You have to provide new sample data with this issue.
Sample data does have those rows. For example, if you search this text in Bold in the dataset, you will find the related row. I am also providing the sample data again.
EN-PR - EN-PR - Engine Full Performance Restoration
P783277]
One additional question.
The sample data I had provided had only one column but in my actual data set, I have multiple columns which I want to populate in the final step. Is it the group by where the column names have to be added to show them as well? Please review my sample data.
DescriptionUtilisationColumn4RateAmount
|
- dufoq32 years agoCommunity Champion
vineshparekh, try this. If there is still some issue, upload your pdf somewhere and provide me a download link please.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("1VlbT9swGP0rFs+u5ftlb1BWkFZYBZsmDfUhKgGq9YJC2e+fY6dt0lwaXG/SIiDYgu98t3P8JX14ODsfDYy8AQNwPs+esmSZAiPBzXq1eQH3m+x9tnnPkgUYvqSzX/aPHu5vPwEhxPQMnhGEsb3dfLu2P4G7FKZ+E2yvYmcKHdLFsAx0kbzNZ42mKSeI5nZG12VjTJWsa2goR3xnm+IvFesUQ4wxGA2PxWGEtzoalrEAcMZLO5zobSjjq8HXa2tmd09Wj/PVM7hKkwyM02fw9XeavSTvi4Y0UShFOUu7dREHMbRSDrsOrock+KAexY7Dmnjn9/fvZb9tWkj+r3a7UgQqKs4zpZDwBj/fDiZ31tDuvnqer1Iwel8swCTNntbZMlnNUnCXvm3WWbKZr1fWzv4rtzFRmlHO2pqAsD06o1DIXeYs6Hjiwf3dg4/t4i59XSSzdJmuNs3lJrkZ7ZdEQGYUkrFDau3r9pB6d9m+EeQUDIbrLEtnuSvgKVsvwWuazdePAJPBZTqzNKEMbNaA7Zf73gF/r0XjeHa0p3tpTO4LOHCmVrY+zlGJkfsFnLXJlIGSaiTI1r2Pi220zB1T5xAFzZ3LSWUOwZol1PZ6wayQiEDl+5iGbZ2c/BgOfl5iglm17LWK9/bDYMRq0R7oIhU7XSz86K1QTfIhpyEJq5elInUSYi6QoQdeRlK8Jpb18rqBVRWRFJAw29yi7LaDtOdgaJb/t+zmof6D7AYJlsqPOozM8elQWiR90rHShlU/JQQ3J2qdw6L9hsX80qXYepxKzjwhvoE6Bl8Hhw0yMu6IInTugPS57Jz6XM8oGn3uE6YlBeUGtSvI7RD3odzqjtK5awBAw67fDyaCDgonhAYx4guhhG6iX318ZFpuA4zXLAVfMJKqmzAcYsORMnHxJfaxO/RumePKDgw8uI8kaUGqixzHGqlTOsljcdxP5YiSp2lqAVccpJ2iQyD1696s98abOqRMQMKhsfFyEbc9FO9KZC9OxvOllSrtiQgUInNy1EFKa5oYcqhDBCrbr5qfEp/0QJwdJT3DdraRH3oqbTZdZzm1YybD4dlySET1nWQUL51OYQ+J1qAQiNJuoaZ2YmaI8MivXhw8Nf7Ny9HBRrHd24SY03pzBqqTgIJc8JJ+f/ykwF2V7Uu/kGMDBwUYcmJECbHH4YGb6FiXFGLFjkWexHnxVEOOvfnK96I3qyKN6HWFy/dyUp2gDKYOdZhiR1IpSkA9tNS0fUBBGcKyQne/EzeD1ClO/vFEw7OcRoRsNzQUlhCGRcZ378916+caglUdEu5xf/oH", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Description = _t, Utilisation = _t, Column4 = _t, Rate = _t, Amount = _t]), SourceColNames = List.Buffer(Table.ColumnNames(Source)), StepBack = Source, TrimmedText = Table.TransformColumns(StepBack, List.Transform(SourceColNames, (colName)=> {colName, Text.Trim, type text})), ReplacedValue = Table.ReplaceValue(TrimmedText, null, null, (x,y,z)=> if List.Contains({"", "-"}, x) then null else x, SourceColNames), AddedIndex = Table.AddIndexColumn(ReplacedValue, "Index", 0, 1, Int64.Type), Ad_GroupHelper = Table.AddColumn(AddedIndex, "GroupHelper", each if (try Text.Range([Description], 2, 1) otherwise null) = "-" then [Index] else null, type text), FilledDown = Table.FillDown(Ad_GroupHelper,{"GroupHelper"}), GroupedRows = Table.Group(FilledDown, {"GroupHelper"}, {{"Description", each Text.Combine([Description], " "), type text}, {"FirstRow", each Table.FirstN(Table.SelectColumns(Table.FillUp(_, SourceColNames), List.Skip(SourceColNames)), 1) , type table}}), ExtractedTextBeforeDelimiter = Table.TransformColumns(GroupedRows, {{"Description", each [ a = Text.PositionOf(_, "]", Occurrence.First) +1, b = Text.Range(_, 0, if a > 0 then a else null ) ][b], type text}}), Ad_SN = Table.AddColumn(ExtractedTextBeforeDelimiter, "SN", each [ a = Text.PositionOf([Description], "[SN") +1, b = Text.PositionOf([Description], " ", Occurrence.Last), c = Text.Range([Description], if a > 0 then a else if Text.Contains([Description], "]") then b else Text.Length([Description])) ][c], type text), CleanDescription = Table.ReplaceValue(Ad_SN, each [SN], null, (x,y,z)=> if y = "" then x else Text.TrimEnd(Text.Replace(x, y, ""), {"[", " ", "-"}), {"Description"}), CleanSN = Table.ReplaceValue(CleanDescription, null, null, (x,y,z)=> if x = "" then null else Text.Replace(Text.Trim(x, {" ", "]"}), "SN: ", ""), {"SN"}), ReorderedColumns = Table.ReorderColumns(CleanSN,{"GroupHelper", "Description", "SN", "FirstRow"}), ExpandedFirstRow = Table.ExpandTableColumn(ReorderedColumns, "FirstRow", {"Utilisation", "Column4", "Rate", "Amount"}, {"Utilisation", "Column4", "Rate", "Amount"}), RemovedGroupHelper = Table.RemoveColumns(ExpandedFirstRow,{"GroupHelper"}), ChangedType = Table.TransformColumnTypes(RemovedGroupHelper,{{"SN", type text}, {"Column4", type text}, {"Utilisation", Currency.Type}, {"Rate", Currency.Type}, {"Amount", Currency.Type}}, "en-US") in ChangedType- vineshparekh2 years agoHelper I
Thanks dufoq3
This step is pulling null in the "GroupHelper" column and because of that, description gets combined for all those lines. I have attached screenshot of those lines. Thanks!
Table.AddColumn(#"Filtered Rows", "GroupHelper", each if (try Text.Range([Description], 2, 1) otherwise null) = "-" then [Index] else null, type text)
- dufoq32 years agoCommunity Champion
I assumed that this behavior is ok. Could you provide correct result of such lines pls?