Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Strange Filter Situation Power Query

I admit I'm a little lost with where to begin with something I'm trying to do in power query.   I made up some dummy data to imitate the problem I'm trying to solve.    My boss wants me to only k...
  • lbendlin's avatar
    4 years ago
    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nZVNagMxDIWvMgxdmlqS/9dd9wQhi1AKDYSkpFnk+FWaGSPFbsHNKgp8z3rys7LZzDib+WV3eT9/7g+H3Zkr8BaiJSC8F+jWYnqalg+ZWOgZ4PbjvDWLzOntdDo+QiMKr6fLxzh//eGpNUKW4VWGhKtVBpNBSrILUj4kMyCw2hjC7y7cDd8dL/sv/oJgqTKIFrCdwzRlAKngpUKxFWExDB2+aDy0Y4wWcrXBRWlsBOOTlyqxpyKOFzBlkyLIEaYWduJULrAzCDSeouwh93ogL5w4aGW8geikTOlaiUKGOjLBRFS5KCpYCvobRJAX6mwdYrDNFNCAvk1ECbP3LOiHNGBLk6TZdR1e6s6Ou9e8SjMfrcLYz7LiVZaTpZqBLHr53Xwny7zbqu1bkXtBSjpI2Ekzdx/k027cUDElRnWR8XG34H8UxHLB7nsS2HXhkpwjiZt3thljuxKw85L4aKrdc5Ga28gmOLWgsfOSeLE78a6p0w2ZuuAmoVPnKKkhiXWQYwLLnw20XmQmQYZdrMkYvPqzAGVFQiMKq5Mhno1svwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Insect ID" = _t, #"Insect Description" = _t, Start = _t, Finish = _t, #"Insect Value" = _t, #"Want to Keep this Row" = _t]),
        #"Added Custom" = Table.AddColumn(Source, "Single", each let s=Table.SelectRows(Source,(k)=>[Insect ID]=k[Insect ID]) in Table.RowCount(s)=1 and s[Insect Description]{0}="Caterpillar"),
        #"Filtered Rows" = Table.SelectRows(#"Added Custom", each [Insect Description] <> "Cocoon" and [Finish] <> " " and ([Insect Description] <> "Caterpillar" or [Single] = true))
    in
        #"Filtered Rows"

    How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".