cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

Re: Reset filter by date

AMAZING stuff, Warren!  Thanks for your patience.  The PowerApps syntax is a little glitch for me and has me tearing my hair out sometimes.  What an amazing asset this forum is for beginners.  Certainly helps those who may have given up on the this platform (like me).

 

Thx again!

Highlighted
Super User III
Super User III

Re: Reset filter by date

No problems @slhangen ,

If you have a good look at the formula, it is not that complex. You have to write it "from the inside out" - so

  1. You have the list 'AT HOME LEARNING STUDENT CONTACT LOG'​ as the base for the gallery
  2. You then want to filter it and have two possibilities - there is a value in the date or not. 
  3. In both cases, it also has to be filtered by user name
  4. You write both possible filters separately and then enclose these in an If statement to see which one to apply
  5. Then put the first sort statement around this, then the second one around that.

The date filter is a bit tricky - you will see other variations turning them into text and some using DateAdd - they all work, but this is the one I use. Also the Blank date test has variations, but again, this one always works for me.

Highlighted
Helper V
Helper V

Re: Reset filter by date

Ok, Warren, take this on only if dare.

 

On another screen I have another gallery.  This gallery displays student contacts by date and all users (no need to filter out current user only).

 

Your DateDiff argument allows me to filter out contacts on a specific date and displays all dates on refresh button click (awesome, BTW).

 

I need to include one more filter.  I have a combobox (ugh!) that will filter users.

 

So basically on screen entry I want to display all users and contact dates.

Then I would like to select out dates and users and, possible, return a message it there is not contact by selected user on selected date, eg: No Contact on this Date.

 

This what I have for the gallery filtered by User ComboBox, which works great:

//Displays All Contacts
If(ddLogContactPerson.SelectedText.Result="All Contactors",SortByColumns('AT HOME LEARNING STUDENT CONTACT LOG',"LogContactDate",Descending,"LogStudentName",Ascending,"LogContactPerson",Ascending),
//Displays by Contact Person
SortByColumns(Filter('AT HOME LEARNING STUDENT CONTACT LOG',LogContactPerson=ddLogContactPerson.SelectedText.Value),"LogContactDate",Descending,"LogStudentName",Ascending,"LogStudentName",Ascending,"LogContactPerson",Ascending))

 

This is what makes the Gallery display dates correctly: 

Sort(Sort(If(Value(dpSelContactDate.SelectedDate)=0,
'AT HOME LEARNING STUDENT CONTACT LOG',
Filter('AT HOME LEARNING STUDENT CONTACT LOG',
DateDiff(LogContactDate,dpSelContactDate.SelectedDate,Days)=0)
),
LogStudentName,
Ascending
),
LogContactDate,
Descending
)

Screenshot attached

I would not blame you, if you ran off screaming.  My ideas are a lot further along than my coding skills.

ContactScreenShot.jpg

 

Highlighted
Super User III
Super User III

Re: Reset filter by date

Hi @slhangen ,

Daring and achieving might be two different things - I can't possibly test this (you may also have to check commas and brackets)

Also you have referred to ddLogContactPerson.Selected. as both Result and Value - you will need the correct one in here.

With(
   {
      bCont: ddLogContactPerson.Selected.Result="All Contactors",
      sCont: ddLogContactPerson.Selected.Result,
      sDate: dpSelContactDate.SelectedDate,
      bDate: Value(dpSelContactDate.SelectedDate)=0
   },
   SortByColumns(
      If(
         !bCont && !bDate,
         'AT HOME LEARNING STUDENT CONTACT LOG',
         bCont && !bDate,
         Filter(
            'AT HOME LEARNING STUDENT CONTACT LOG',
            LogContactPerson=sCont
         ),
         bDate && !bCont,
         Filter(
            'AT HOME LEARNING STUDENT CONTACT LOG',
            DateDiff(
               LogContactDate,
               sDate,
               Days
            )=0
         ),
         Filter(
            'AT HOME LEARNING STUDENT CONTACT LOG',
            LogContactPerson=sCont &&
            DateDiff(
               LogContactDate,
               sDate,
               Days
            )=0
         )
      ), 
      "LogContactDate",
      Descending,
      "LogStudentName",
      Ascending,
      "LogContactPerson",
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Helper V
Helper V

Re: Reset filter by date

Thx so much.  I may have bit off more than I can chew here.  Red lines everywhere.  I will try and tweak and learn what is going on with this code going forward and may be able to hash it out. 

 

Thanks again for all your help on this!

Highlighted
Super User III
Super User III

Re: Reset filter by date

Thanks @slhangen ,

Basically the With() statement sets (very) temporary Variables you can then refer to in the rest of the code. If you want to repeat what is in them every time in the code below, you do not need this.

I actually do not use SortByColumns as lot (just a personal preference), I tend to use ShowColumns and Sort, so I have rarely tested something like that inside of one of these.

However the next bit is just a heap of If scenarios (there are four possibilities to map the Filter on - you just line them up, with the last one actually being the "else" if not the three above).

Highlighted
Helper V
Helper V

Re: Reset filter by date

Thank you for all of your help.  I really would have quit a while ago if it were not for the strong support from these forums.  I will get back to this when I am done with some other issues.

 

Thx again.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Come join us today! Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (3,611)