Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Filter Gallery using custom field

(0) ShareShare
ReportReport
Posted on by

Hi,

 

I have created a Gallery for a SP list. On the Gallery I created a custom field to calculate a value.

I added a slider so that I can Filter the gallery based on this value. 

 

However I'm not able to use this column since it is not a field on the SP list. I tried to filter using the Gallery name and this column but still not able to figure it out. Any help

 

 

 

  • Verified answer
    StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at
    Re: Filter Gallery using custom field

    Hi @indhaa 

     

    With(
     {
     _item: AddColumns(
     DeviceOrdering,
     "OverDueCalculated",
     With(
     {
     DateRange: ForAll(
     If(
     ThisRecord.DueDate > Today(),
     Sequence(
     ThisRecord.DueDate - Today(),
     0
     ),
     Sequence(
     Today() - ThisRecord.DueDate,
     0
     )
     ),
     Weekday(
     DateAdd(
     DueDate,
     Value
     )
     )
     )
     },
     If(
     IsBlank(DueDate) || DueDate > Today(),
     0,
     DateDiff(
     DueDate,/* Start Date */
     Today()/* End Date */
     ) - CountRows(
     Filter(
     colHoliday,
     HolidayDate >= DueDate,
     HolidayDate <= Today()
     )
     ) - CountRows(
     Filter(
     DateRange,
     Value = 6
     )
     ) - CountRows(
     Filter(
     DateRange,
     Value = 7
     )
     )
     )
     )
     )
     },
     SortByColumns(
     Filter(
     _item,
     OverDueCalculated < Slider1.Value && StartsWith(
     Title,
     TitleFilterInput.Text) &&
     RequesterDepartment = RequesterDeptFilterInput.Selected.Result &&
     Priority.Value = PriorityFilterInput.Selected.Value 
     ),
     "ID",
     Descending
     )
    )

     

    I assumed other filter already working

    && StartsWith(Title,TitleFilterInput.Text) &&
    RequesterDepartment = RequesterDeptFilterInput.Selected.Result &&
    Priority.Value = PriorityFilterInput.Selected.Value

  • indhaa Profile Picture
    on at
    Re: Filter Gallery using custom field

    Hi Stalin,

     

    Thanks for your help

     

    I need a little help. Already I have other filtering in the gallery. When I try to amend it with the overdue code you provided I'm getting an error. With only the Overdue filter it is working but when I try to combine I'm having a issue. Below is the code I'm trying to combine

    SortByColumns(
     Filter(
     DeviceOrdering, 
     StartsWith(RequestTitle, TitleFilterInput.Text) &&
     RequesterDepartment = RequesterDeptFilterInput.Selected.Result &&
     Priority.Value = PriorityFilterInput.Selected.Value 					
     ), "ID", Descending)

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at
    Re: Filter Gallery using custom field

    Hi @indhaa 

     

    We need to change the way OverDueCalculated.

     

    Set the Items property of Gallery to (Using Existing code that I sent)

    //DeviceOrdering
    Filter(
     AddColumns(
     DeviceOrdering,
     "OverDueCalculated",
     With(
     {
     DateRange: ForAll(
     If(
     ThisRecord.DueDate > Today(),
     Sequence(
     ThisRecord.DueDate - Today(),
     0
     ),
     Sequence(
     Today() - ThisRecord.DueDate,
     0
     )
     ),
     Weekday(
     DateAdd(
     DueDate,
     Value
     )
     )
     )
     },
     If(
     IsBlank(DueDate) || DueDate > Today(),
     0,
     DateDiff(
     DueDate,/* Start Date */
     Today()/* End Date */
     ) - CountRows(
     Filter(
     colHoliday,
     HolidayDate >= DueDate,
     HolidayDate <= Today()
     )
     ) - CountRows(
     Filter(
     DateRange,
     Value = 6
     )
     ) - CountRows(
     Filter(
     DateRange,
     Value = 7
     )
     )
     )
     )
     ),
     OverDueCalculated < Slider1.Value
    )

     

    in the gallery Set the Text property of OverDue Label control to

    ThisItem.OverDueCalculated

     

    Note: Change the SliderName (Slider1)

  • indhaa Profile Picture
    on at
    Re: Filter Gallery using custom field

    Hi,

     

    So my Gallery name is DetailedView and the column name is OverDueCount. This is the field you helped me with to do the calculation.

     

    This is Not a collection and NOT a SP column .

     

    So I added a Slider and want to filter based on this column.  I haven't done a filter like this before based on a custom field on a gallery and my code getting an error.

     

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at
    Re: Filter Gallery using custom field

    Hi @indhaa 

     

    The column needs to be in Source data or the collection.

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,026 Most Valuable Professional

Leaderboard