Search code examples
powerappspowerapps-canvaspowerapps-formula

Filter on showColumn & distinct inside my power apps formula


I have this formula which is working correctly:-

ClearCollect(
     colUniqueDates,
     AddColumns(
         RenameColumns(
             Distinct(
                 'Grant Applications',
                 Title
             ),
             "Result",
             "Title"
         ).Title,
         "Level",
         1
     )
 ); 

but i wanted to add filter to is, as follow:-

enter image description here

but i got name is not recognized, any advice?


Solution

  • The table that is returned by the AddColumns call in your expression only has two columns: "Title" (which was renamed from "Result" in the result of the Distinct function) and "Level" (which was added by the AddColumns function). There is no "CurrentState" column in that table, which is why you see this error.

    Assuming that the original table / data source 'Grant Applications' has this "CurrentState" column, you can move the filtering to where you still have that column in your table, something along the lines of the expression below:

    ClearCollect(
         colUniqueDates,
         AddColumns(
             RenameColumns(
                 Distinct(
                     Filter(
                         'Grant Applications',
                         CurrentState = "1" Or CurrentState = "0"),
                     Title
                 ),
                 "Result",
                 "Title"
             ),
             "Level",
             1
         )
     );