Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Gallery display items - Toggle to include records where date is not blank

(0) ShareShare
ReportReport
Posted on by 134

I have a gallery with the following Items property which enables a search text box and a drop down filter based on a specific Manager field.  This all works fine.

SortByColumns(
Search(
Filter(
'IKEA Rota List',
false || IsBlank(ManFilter.Selected.Value) || Manager.Value = ManFilter.Selected.Value
),
NameSearch.Value,
"Title"
),
"Title",
SortOrder.Ascending
)

 

I want to add a toggle that refers to a Leaver date field.  If on then only display records where leaver date is <> Blank (i.e. they are a leaver)

 

If off then display records where leaver date is blank.

 

Can someone help me?

Categories:
  • Mawdman85 Profile Picture
    Mawdman85 134 on at
    Re: Gallery display items - Toggle to include records where date is not blank

    @mmbr1606 worked it out, it wanted LeaverToggle.Checked rather than .Value

     

    Thank you for swift response

     

    Mawdman85_0-1708356201342.png

     

  • mmbr1606 Profile Picture
    mmbr1606 10,444 on at
    Re: Gallery display items - Toggle to include records where date is not blank

    whats the error you are recieving?

  • Mawdman85 Profile Picture
    Mawdman85 134 on at
    Re: Gallery display items - Toggle to include records where date is not blank

    @mmbr1606  giving me an error in the If statement - I have checked the syntax of the 'Leaver Date' field name and it is accepting it in that part of the statement so I don't think it's the naming convention.

    Mawdman85_0-1708355846507.png

     

  • Sickle-Cell Profile Picture
    Sickle-Cell 600 on at
    Re: Gallery display items - Toggle to include records where date is not blank

    Hi @Mawdman85 , try something like this :-

    Replace the LeaverDate part with whatever you are using to capture whether or not you want to filter it being true or not, this code essentially just checks if a date exists within a date picker or not, but you could easily replace that with a check box or similar.

    If(
     IsBlank(LeaverDate.SelectedDate),
     SortByColumns(
     Search(
     Filter(
     'IKEA Rota List',
     And(
     false || IsBlank(ManFilter.Selected.Value) || Manager.Value =
     ManFilter.Selected.Value, 
     IsBlank(LeaverDate.SelectedDate)
     ) 
     ),
     NameSearch.Value,
     "Title"
     ),
     "Title",
     SortOrder.Ascending
     ),
     SortByColumns(
     Search(
     Filter(
     'IKEA Rota List',
     And(
     false || IsBlank(ManFilter.Selected.Value) || Manager.Value =
     ManFilter.Selected.Value, 
     !IsBlank(LeaverDate.SelectedDate)
     ) 
     ),
     NameSearch.Value,
     "Title"
     ),
     "Title",
     SortOrder.Ascending

     

  • Verified answer
    mmbr1606 Profile Picture
    mmbr1606 10,444 on at
    Re: Gallery display items - Toggle to include records where date is not blank

    hey @Mawdman85 

     

    please try this:

    SortByColumns(
     Search(
     Filter(
     'IKEA Rota List',
     false || IsBlank(ManFilter.Selected.Value) || Manager.Value = ManFilter.Selected.Value,
     If(
     LeaverToggle.Value,
     !IsBlank('Leaver date'), // If the toggle is on, filter for non-blank leaver dates
     IsBlank('Leaver date') // If the toggle is off, filter for blank leaver dates
     )
     ),
     NameSearch.Value,
     "Title"
     ),
     "Title",
     SortOrder.Ascending
    )
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,495

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,822

Leaderboard