Filter a specific data structure

Iron Contributor

Dear Experts,

                   I have a log file where I need to filter/extract specific log structure as below:-



from the attached txt file, the log mask is "0xB89C NR5G MAC Flow Control" and it's structure as shown above, Can you please share how to achieve this via PQ?


Thanks in Advance,



1 Reply


Do you wish to extract rows that contain "MAC Flow Control" and the 16 rows beneath it?

If so, below works.


Though it is very slow, not sure is it because my poor coding or just because the file is too large....

  Source = Table.FromColumns({Lines.FromBinary(File.Contents("OnePlus9Pro_SDX60_prachConfigurationIndex_40 successfull_RACH.txt"), null, null, 65001)}),
  AddFlag = Table.AddColumn(Source, "ContainsText", each Text.Contains([Column1], "MAC Flow Control")),
  GetRowIndices = List.Positions(AddFlag[ContainsText]),
  zipped = List.Zip({GetRowIndices, AddFlag[ContainsText]}),
  GetRelevantRowIndices = List.Transform(List.Select(zipped, each _{1} = true), each _{0}),
  ListGenerator = (x)=>List.Generate(() => x, each _ < x+16, each _ + 1),
  GetRelevantSlices = List.Transform(GetRelevantRowIndices, each ListGenerator(_)),
  IncludedRowIndices = List.Combine(GetRelevantSlices),
  RelevantRows = List.Transform(IncludedRowIndices, each AddFlag[Column1]{_}),
  #"Converted to table" = Table.FromList(RelevantRows, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
  #"Converted to table"