web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter on Showcolumn &...
Power Apps
Unanswered

Filter on Showcolumn & distinct

(0) ShareShare
ReportReport
Posted on by 3,514

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:-

 

johnjohn123_0-1660654677642.png

but i got name is not recognized, any advice?

Categories:
  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @johnjohn123 ,

     

    The Distinct function returns a single column ('Result') which you are renaming to 'Title'. You then add a second column ('Level'), so there is no 'CurrentState' column in your data source to evaluate, hence the error.

     

    If you want to use it, you need to include it in the AddColumns statement.

  • johnjohn123 Profile Picture
    3,514 on at

    @BCBuizer  not sure where exactly inside the formula i need to reference the currentState? this will give an error, as well:-

     

    johnjohn123_0-1660655680173.png

     

     

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @johnjohn123 ,

     

    Below is how it might look:

    ClearCollect(
     colUniqueDates,
     AddColumns(
     RenameColumns(
     Distinct(
     'Grant Applications',
     Title
     ),
     "Result",
     "Title"
     ).Title As _Titles,
     "Level",
     1,
     "CurrentState",
     LookUp('Grant Applications',Title = _Titles[@Title]).CurrentState
     )
     );

     Since I don't know where the CurrentState value should come from, you may have to tweak this a bit.

  • johnjohn123 Profile Picture
    3,514 on at

    @BCBuizer currentState is a field inside the "Grant Applications" sharepoint list, also i do not want to lookup as the result will contain more than one record, i want to filter

     

     

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @johnjohn123 ,

     

    Understood you have multiple items, but then what is the purpose of the Distinct function? Perhaps you can share the purpose of what you're trying to achieve?

  • johnjohn123 Profile Picture
    3,514 on at

    @BCBuizer I want to group a gallery by Title something as mentioned in this link https://www.matthewdevaney.com/group-the-items-in-a-power-apps-gallery/  .. but I want to add filtering to the formulas as mentioned in my question, hope this clarify the issue. Thanks 

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @johnjohn123 ,

     

    Based on the example in the blog, I came to this code for the collections:

     

    // Create a collection of all Grant Applications
    ClearCollect(
     colGrantApplications,
     AddColumns(
     ShowColumns(
     'Grant Applications',
     "Title",
     "CurrentState"
     ),
     "Level",
     2
     )
    );
    // Create a collection of all unique Title values
     ClearCollect(
     colUniqueTitles,
     AddColumns(
     RenameColumns(
     Distinct(
     'Grant Applications',
     Title
     ),
     "Result",
     "Title"
     ).Title,
     "Level",
     1
     )
     );
    // Combine both collections into a single collection
    ClearCollect(
     colCombinedApplications,
     colGrantApplications,
     colUniqueTitles
    );
    // Sort the combined collection
    ClearCollect(
     colSortedAppointments,
     SortByColumns(
     colCombinedApplications,
     "Title",
     "CurrentState",
     "Level"
     )
    );

     

    You might want to add further columns as currently the colCombinedApplications collection only contains the "Title" "CurrentState" and "Level" columns.

     

    Once completed the tutorial needs to be completed from this point onwards: https://www.matthewdevaney.com/group-the-items-in-a-power-apps-gallery/#Change-The-Gallery-Datasource-To-The-Grouped-Collection

  • johnjohn123 Profile Picture
    3,514 on at

    @BCBuizer @But as I mentioned I need to add filter to the formula this is my main question 

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @johnjohn123 ,

     

    Basically the code has 4 sections and you can insert the filter anywhere where the data source includes the columns you want to filter. I inserted the filter in the first two sections: The first is to reduce the number of items that have to be processed in sections 3 and 4, and the second to prevent any unique values from being created that do have an application against it, but do not meet the conditions:

     

    // Create a collection of all Grant Applications
    ClearCollect(
     colGrantApplications,
     AddColumns(
     ShowColumns(
    			Filter(
    				'Grant Applications',
    				CurrentState = "0" || CurrentState = "1'
    			),
     "Title",
     "CurrentState"
     ),
     "Level",
     2
     )
    );
    // Create a collection of all unique Title values
     ClearCollect(
     colUniqueTitles,
     AddColumns(
     RenameColumns(
     Distinct(
    				Filter(
    					'Grant Applications',
    					CurrentState = "0" || CurrentState = "1'
    				),
     Title
     ),
     "Result",
     "Title"
     ).Title,
     "Level",
     1
     )
     );
    // Combine both collections into a single collection
    ClearCollect(
     colCombinedApplications,
     colGrantApplications,
     colUniqueTitles
    );
    
    // Sort the combined collection
    ClearCollect(
     colSortedAppointments,
     SortByColumns(
    		colCombinedApplications,
     "Title",
     "CurrentState",
     "Level"
     )
    );

     

     

  • johnjohn123 Profile Picture
    3,514 on at

    @BCBuizer  i do not think Filter can be applied in this way , as your code will raise many errors, as follow:-

     

    johnjohn123_0-1660685611546.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard