Forum Discussion

alexmag92's avatar
alexmag92
Regular Visitor
8 years ago
Solved

Using filter in Query Editor especificing a cell from another table

Using filter in Query Editor with a value (text) from another table, especificing a cell from a column.

 

code from Advanced Editor (I cleaned some parts to simplify):

 

...
filter = (table1[column1]),              # Uses filter as cells(1,1) from table 1, how?
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [column1] = filter), 
...

 

 

att,

Alexandre

  • If I understand you correctly, you want to know how to get the first value from a table.

     

    You can use Table.FirstValue, syntax:

     

    Table.FirstValue(table as table, optional default as any) as any

    If you supply a default value, then this value will be returned if the table is empty.

     

3 Replies

  • MarcelBeug's avatar
    MarcelBeug
    Community Champion

    If I understand you correctly, you want to know how to get the first value from a table.

     

    You can use Table.FirstValue, syntax:

     

    Table.FirstValue(table as table, optional default as any) as any

    If you supply a default value, then this value will be returned if the table is empty.

     

    • alexmag92's avatar
      alexmag92
      Regular Visitor

      MarcelBeug

       

      Im trying to filter table1[Group_Column] with a value from the first row and column of table2[Filter_Column]

       

      Table1

      Group_ColumnDescription_Column
      Group_ADescription1
      Group_ADescription2
      Group_BDescription3
      Group_ADescription4

       

      Table2

      Filter_Column
      Group_A

       

      and when I put the code:

       

      #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Group_Column] = Table2[Filter_Column]))

       

      Came: 'This table is empty'

    • alexmag92's avatar
      alexmag92
      Regular Visitor

      It works, using this:

       

      = Table.SelectRows(#"Changed Type", each ([Group_Column] = Table.FirstValue(Table2)))

       

      ty MarcelBeug.

       

      att,

      Alexandre.