cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EpicTriffid
Resolver I
Resolver I

Displaying distinct items sorted by soonest month

Afternoon all,

 

I'm looking to display two columns ("Month", "FAQ Item Name") from a SharePoint list that contains information about when certain reports are updated for an information app i'm creating.

I need to see a distinct list of "FAQ Item Name" (Which has multiple iterations of items each with different dates) where it shows the item with the soonest occurring month. This is so I can create a table that shows, for example, the next three reports that will be updated. I pull this into a "calPre" collection.

 

There is a slight problem in that "FAQ Item Name" is a lookup column, so it comes into a collection as a record that a table can't parse the text from, as well as having a number of blank records in that column that i need to filter out.

 

My solution to this is to pull that first collection (calPre) into a second collection (calPre2) that removes my blank rows and just gives me the two columns i'm interested it:

 

Clear(calPre2);
ForAll(
    Filter(
        calPre,
        Not(IsBlank(FAQ_x0020_Item_x0020_Name))
    ),
    Collect(
        calPre2,
        {
            FAQItem: Text('FAQ Item Name'.Value),
            dateMonth: Month
        }
    )
);

 

4.PNG

So now I have my two columns. You can see an instance above of the information that I might want to sort out: I would need to have a distinct list of the FAQItem column where the items that are returned are the ones with the soonest occurring date. My thinking is that I would create a new collection every time the app opens that would recalculate this, and I could sort it by the dateMonth column, then show the TopN number of results to get my 3 reports that will be updated soon. 

 

I've tried GroupBy, AddColumns, filtering by date, all the variations of Text() or Distinct().value/result and I either don't get anything returned, the dates are wrong, or it brings back lines and lines of [Object object] errors. 

 

I'm having real difficulty with something that I thought would be quite simple. Any help would be greatly appreciated!

10 REPLIES 10

@RandyHayes 

 

I just found that the syntax you provided was ever so slightly off for what I needed (That's not in any blame by the way; you provided a fantastic solution for a problem that I didn't fully explain!). However, the explanations on the reading of the syntax and the functions were informative enough that I was able to go in and change my code really quite easily to pop out a perfect solution. 😄

 

If you're ever in Manchester, UK, I'm buying you a beer! 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,296)