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 / Visible>If Statement b...
Power Apps
Unanswered

Visible>If Statement based on DateDiff

(0) ShareShare
ReportReport
Posted on by 118

I have a Gallery connected to SP List #1 and have added a Label2 to Gallery card that pulls date form SP List #2.  I'm trying to set Gallery Item Visible based on If(DateDiff(Label2,Now(),Days)>1,true,false).  For some reason this doesn't work (nothing visible even though there are items where DateDiff(Label2,Now(),Days)>1).  I can add Label that displays result of DateDiff(Label2,Now(),Days) and it calculates correctly.  Ideas? 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Microbes 

    Can you explain a little more about what you are trying to make visible or not?  You cannot make an entire row of a gallery be visible or not, only the individual controls in the row or the entire gallery.

     

    You mention the Item property - but what control is it with an Item property?  The Gallery has an Items property.  Perhaps you meant that?

  • EG-31080115-0 Profile Picture
    118 on at

    Thanks @RandyHayes , I was in fact trying to hide Gallery row and as you pointed out this isn't possible. What I hoped to accomplish is,

    SP List#1 (Area, Frequency, Task, Tools) is reference table which lists details for aforementioned columns.

    SP List#2 (Area, Frequency, Task, Tools, Date_Completed, Initials) is log where task completion is recorded.

    Gallery would have items that meet a DateDiff criteria [eg DateDiff(Now(), Date_Completed,Days)>1]

    What I attempted, unsuccessfully, was to connect Gallery to SP List#1 to display Task, added a Label to Gallery that used lookup latest Date_Completed from SP List#2 then try to use DateDiff(Now(),Date_Completed,Days)>1 to hide Gallery row. 

  • EG-31080115-0 Profile Picture
    118 on at

    So, I added "Last_Completed" column to my SP List#1 to be able to filter Gallery on date, but now trying to figure out how to incorporate date difference into filter so that only Gallery items that meet date criteria (e.g. Now() - Last_Completed > 1) are included.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Microbes 

    So yes, this is the way to exclude rows from your Gallery - in the Items property filter!

     

    What you'll need is to use a formula such as this:

    Filter(yourList1, 
     Last_Completed < Now()
    )

    If you want a larger range, then you can use a formula such as this:

    With({_minDate: DateAdd(Now(), -7, Days)}, // change the 7 to a range you want
     Filter(yourList1, 
     Last_Completed < _minDate
     )
    )

    You could do the dateadd in the filter, but it is always best to put calculations outside of the filter function to avoid delegation issues where the formula editor has a hard time adjusting to a delegable statement.

     

    You could have stayed with the Date_Completed from list #2 and done some similar things, but having a column with the actual value in list #1 is helpful from a performance aspect.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,055

#2
Valantis Profile Picture

Valantis 666

#2
11manish Profile Picture

11manish 666

Last 30 days Overall leaderboard