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

Show only most recently modified items

Hi, hoping someone can help me here or let me know if this is not possible!

I have a gallery displaying items from a document library. There is a column called ‘Type and multiple documents can have the same type value.

Is it possible to filter the gallery to only show a single item for each type based on the most recently modified?

Hope this makes sense,
Thanks in advance!
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Show only most recently modified items

Hi @MP4249 ,

Please consider modify your formula as below:

1. If the "Type" column is a Text type column:

Set the Items property of the Gallery to following:

AddColumns(
            GroupBy('SP Library', "Type", "GroupData"),
            "FileNameWithExtention",
            First(Sort(GroupData, Modified, Descending)).'File name with extension',
            "ModifiedTime",
            First(Sort(GroupData, Modified, Descending)).Modified,
            "Modifier",
            First(Sort(GroupData, Modified, Descending)).'Modified By'.DisplayName // Modify formula here
)

Then within your Gallery, add several Labels, set the Text property to following:

ThisItem.FileNameWithExtention
ThisItem.ModifiedTime
ThisItem.Modifier

 

2. If the "Type" column is a Choice type column:

Set the Items property of the Gallery to following:

AddColumns(
            GroupBy(
                     AddColumns('SP Library', "TypeValue", Type.Value),
                     "TypeValue", 
                     "GroupData"
            ),
            "FileNameWithExtention",
            First(Sort(GroupData, Modified, Descending)).'File name with extension',
            "ModifiedTime",
            First(Sort(GroupData, Modified, Descending)).Modified,
            "Modifier",
            First(Sort(GroupData, Modified, Descending)).'Modified By'.DisplayName // Modify formula here
)

Please consider take a try with above solution, then check if the the ThisItem.Modifier formula could display proper name value within your Gallery.

 

In addition, you could also consider type the following formula within your Gallery directly:

ThisItem.Modifier.DisplayName

Note: The 'Modifier By' column is actually a Person type column in your SP List.

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
Highlighted
Super User
Super User

Re: Show only most recently modified items

@MP4249 

This is likely achievable through using the GROUPBY and MAX functions.

 

Can you please tell me what type of column 'Type' is?  My answer would be slightly different depending whether Type is a Text column or a Choices column.

Highlighted
Helper II
Helper II

Re: Show only most recently modified items

Hi, it’s actually a text column.

Thanks
Highlighted
Community Support
Community Support

Re: Show only most recently modified items

Hi @MP4249 ,

Could you please share a bit more about the "recently modified"? Is there some date range, e.g. in 2 days?

Could you please show more details about the "Type" in your SP Library? Is it a Choice type column or a Text type column?

Further, do you want to filter your Gallery to display single one item for each Type based on the most recently modified?

 

I have made a test on my side, please consider take a try with the following workaround:

1. If the "Type" column is a Text type column:

Set the Items property of the Gallery to following:

AddColumns(
            GroupBy('SP Library', "Type", "GroupData"),
            "FileNameWithExtention",
            First(Sort(GroupData, Modified, Descending)).'File name with extension', // retrieve the file name from the latest modified record
            "ModifiedTime",
            First(Sort(GroupData, Modified, Descending)).Modified, // retrieve the modified time from the latest modified record
            "Modifier",
            First(Sort(GroupData, Modified, Descending)).'Modified By' // retrieve the modifier from the latest modified record
)

Then within your Gallery, add several Labels, set the Text property to following:

ThisItem.FileNameWithExtention
ThisItem.ModifiedTime
ThisItem.Modifier

 

2. If the "Type" column is a Choice type column:

Set the Items property of the Gallery to following:

AddColumns(
            GroupBy(
                     AddColumns('SP Library', "TypeValue", Type.Value),
                     "TypeValue", 
                     "GroupData"
            ),
            "FileNameWithExtention",
            First(Sort(GroupData, Modified, Descending)).'File name with extension', // retrieve the file name from the latest modified record
            "ModifiedTime",
            First(Sort(GroupData, Modified, Descending)).Modified, // retrieve the modified time from the latest modified record
            "Modifier",
            First(Sort(GroupData, Modified, Descending)).'Modified By' // retrieve the modifier from the latest modified record
)

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper II
Helper II

Re: Show only most recently modified items

@v-xida-msft 

Hi,

 

Thanks for your reply - I have tried but the formula does not like the 'Modifier' text label:

Any ideas what else I could try?

Highlighted
Helper II
Helper II

Re: Show only most recently modified items

@v-xida-msft @mdevaney 

 

Hi,

 

Still having trouble getting this to work, any further help here greatly appreciated - I'm not sure the below solution will work for me... To simplify what I need - I have a document library gallery as per below and I only want to show a single entry against each item in the # column.

 

The Items property is currently set as follows:

 

SortByColumns(Search(DMSDocscol, Searchbox.Text,"Document_x0020_Name","DocumentGroupID"),"Created",Descending)

 

Only showing most recently created or modified would be good, but otherwise any other way of filtering out duplicates is fine as all records will link to the same screen by this # property.

 

pix.png

Highlighted
Community Support
Community Support

Re: Show only most recently modified items

Hi @MP4249 ,

Please consider modify your formula as below:

1. If the "Type" column is a Text type column:

Set the Items property of the Gallery to following:

AddColumns(
            GroupBy('SP Library', "Type", "GroupData"),
            "FileNameWithExtention",
            First(Sort(GroupData, Modified, Descending)).'File name with extension',
            "ModifiedTime",
            First(Sort(GroupData, Modified, Descending)).Modified,
            "Modifier",
            First(Sort(GroupData, Modified, Descending)).'Modified By'.DisplayName // Modify formula here
)

Then within your Gallery, add several Labels, set the Text property to following:

ThisItem.FileNameWithExtention
ThisItem.ModifiedTime
ThisItem.Modifier

 

2. If the "Type" column is a Choice type column:

Set the Items property of the Gallery to following:

AddColumns(
            GroupBy(
                     AddColumns('SP Library', "TypeValue", Type.Value),
                     "TypeValue", 
                     "GroupData"
            ),
            "FileNameWithExtention",
            First(Sort(GroupData, Modified, Descending)).'File name with extension',
            "ModifiedTime",
            First(Sort(GroupData, Modified, Descending)).Modified,
            "Modifier",
            First(Sort(GroupData, Modified, Descending)).'Modified By'.DisplayName // Modify formula here
)

Please consider take a try with above solution, then check if the the ThisItem.Modifier formula could display proper name value within your Gallery.

 

In addition, you could also consider type the following formula within your Gallery directly:

ThisItem.Modifier.DisplayName

Note: The 'Modifier By' column is actually a Person type column in your SP List.

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Helper II
Helper II

Re: Show only most recently modified items

Thank-you this worked!

 

One final question though if you don't mind, how do I also incorporate my original formula into this?

 

SortByColumns(Search(DMSDocscol, Searchbox.Text,"Document_x0020_Name","DocumentGroupID"),"Created",Descending)

 

Thanks,

Mike

@v-xida-msft 

Highlighted
Helper II
Helper II

Re: Show only most recently modified items

Another issue with this is when I attempt to select an item from this gallery using the Form item value: "Gallery.Selected" it now shows an error: Invalid Formula. Expected a value compatible with 'Datasource'

 

What do I need to do to resolve this?

 

Thank-you for your assistance it is greatly appreciated!

 

@v-xida-msft 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (10,420)