Forum Discussion

Lucian's avatar
Lucian
Responsive Resident
5 years ago
Solved

Power Query Select rows between two TEXT values

Hello, I have a problem selecting table rows that are between two text values, and I hope will find someone to point me to the right direction.   I have an table that has one of the columns "Accou...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Lucian 

     

    It is a better explanation now. The original list is your raw data, you need to filter based on your start and end. So your start and end always have the same format - same amount of dot? If yes, here is one way

    start and end is your input

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjU0MtQzMNQzNFWK1UHimqFyzVG5FqhcSzjXwBCJA5IzMkDlGiIpReKA5YyQuEZAEVQumqwxKtcElQv0TSwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Account No" = _t]),
        Input = [start="5121.01.19",end ="5121.02.03"],
        #"Filtered Rows" = Table.SelectRows(Source, each List.Contains({Number.From(Text.Remove(Input[start],"."))..Number.From(Text.Remove(Input[end],"."))},Number.From(Text.Remove([Account No],"."))) and  Text.Length(Text.Select([Account No],{"."}))=Text.Length(Text.Select(Input[start],{"."})) )
    in
        #"Filtered Rows"

     

    if I change [start="51210119",end ="51210203"], then

    to make it easy to understand, I put the Input here in the query, you may have other ways to get the input - another query for example