How can I filter out the most recent n entries?

Hello,

My apologies if this has been asked before, but I’ve been working on this for a week and have not found a solution. Also, first time posting and if there is anything I missed out, please let me know. Thanks in advance!

I have a table with entries of my work sessions and I would like to have a view where I only see the most recent n-amount of entries. My current workaround is to have a form sorted by descending [time stamp].

I would also like to create a graph based on the most recent n-amount of entries. So then I figured I would need “a new set of data”.

My attempts thus far have involved using Slice and VCs. Both of which have no success.
I’ve tried creating a Slice with the expression: [module (wk)]=“MDP Anatomy” AND sort([time stamp],TRUE)
I’ve also created a VCs where I used Sort() to have a descending list based on a given category.

Any help or suggestions would be most appreciated!

Best regards,
Daniel

Data:

Welcome to the AppSheet community.

Please evaluate using ORDERBY() and TOP() functions. Also please take a look at the sample app referred to below. You could use a combination of ORDERBY() and TOP() in a slice filter as well.

https://www.appsheet.com/samples/How-to-find-the-top-four-items-in-a-list?appGuidString=bb25c579-7001-469c-b045-0e425e92d132

4 Likes

Thank you so much for pointing me in the right direction!
I looked at the suggested sample app, which provides a solution to what I want to do. Thank you again for that.

But unlike the sample app, which provides a table when clicking into one of the items, in my app there is an additional “layer”. I’ve replicated the expressions from the sample app, and so I’m not sure why this is an issue.

Any suggestions is most appreciated. Thank you in advance!

top

1 Like

Hi @Danny_W ,

Could you please elaborate? It is not exactly clear how you have implemented and what you are trying to achieve. On which table you wish to have the recent records? Relevant screenshots if possible will help.

2 Likes

Thanks @Suvrutt_Gurjar for the reply!

So my main set of data is in Log. Here is a screenshot.

The main categorisation is based on [module (wk)], and its related table is under “Module filter”.

I’m trying to make it so that I can choose the item from [module] and I only see the most 2 recent entries within Log.

Imitating the sample app, I created a VC in “Module filter” combing TOP() and ORDERBY().

I then created a table view for “Module filter” and the result was the gif from the previous post with the extra “layer”.

Thank you again for your time!

Thank you for all the details @Danny_W . Could you elaborate what you mean by “extra layer”? Is it two related graph views and you do not wish to see one or both graph views?

Or do you wish to see the table view only skipping teh graph views display?

2 Likes

Apologies. Yes, I meant the graph views as the “extra layer”. I only wish to see the table and skip the graph view. I don’t understand why there is a graph view.

Thank you.

Thank you. Do you see a reference view called something as Logs_Inline

If that view is chart type, could you change it to table type view?

2 Likes

I checked, but it is set to table type view.

I then noticed that the unwanted chart “layer” was another ref view I have using Log (Confidence).

I experimented and deleted “Confidence”, then the unwanted layer became “Duration”. The pattern followed with the deletion of “Duration”. After I got rid of all the chart ref views, I was able to have the way I wanted.

So then I created a slice of Log, and then created the ref chart views based on this new slice. Not sure if this is the best way to do this, but it is a solution.

@Suvrutt_Gurjar Thank you so much for your kind assistance!

2 Likes

Nice to know you got a solution @Danny_W

Thank you for the update. All the best with your app-building.

2 Likes