none
Find exact string in a list RRS feed

  • Question

  • Hi,

    I see this example.

    List.FindText(
    
    {
    
        [ Field1 = "hello", Field2 = "world" ],
    
        [ Field1 = "hello1", Field2 = "hello2" ],
    
        [ Field1 = "another test", Field2 = 5 ],
    
        [ Field1 = 1, Field2 = 2 ]
    
    }, "hello")
    
    equals
    
    {
    
        [Field1="hello", Field2 = "world"],
    
        [Field1 = "hello1", Field2 = "hello2"]
    
    }
    

    If I only want the list of 

    {
    
        [Field1="hello", Field2 = "world"]
    
    }

    , what function should I use?

    Thanks


    • Edited by bjzk Wednesday, May 11, 2016 7:10 PM
    Wednesday, May 11, 2016 7:10 PM

Answers

  • let
        list = {[ Field1 = "hello", Field2 = "world" ],
        [ Field1 = "hello1", Field2 = "hello2" ],
        [ Field1 = "another test", Field2 = 5 ],
        [ Field1 = 1, Field2 = 2 ]},
        Result = List.Select(list, each List.Contains(Record.FieldValues(_), "hello"))
    in
        Result
    Does this work for you?
    • Edited by Oguz YildizModerator Wednesday, May 11, 2016 9:45 PM
    • Marked as answer by bjzk Wednesday, May 11, 2016 9:59 PM
    Wednesday, May 11, 2016 9:45 PM
    Moderator

All replies

  • let
        list = {[ Field1 = "hello", Field2 = "world" ],
        [ Field1 = "hello1", Field2 = "hello2" ],
        [ Field1 = "another test", Field2 = 5 ],
        [ Field1 = 1, Field2 = 2 ]},
        Result = List.Select(list, each List.Contains(Record.FieldValues(_), "hello"))
    in
        Result
    Does this work for you?
    • Edited by Oguz YildizModerator Wednesday, May 11, 2016 9:45 PM
    • Marked as answer by bjzk Wednesday, May 11, 2016 9:59 PM
    Wednesday, May 11, 2016 9:45 PM
    Moderator
  • It works. Thanks
    Wednesday, May 11, 2016 9:59 PM