List of 'last' records matching a criteria

HI All, thank you for all the useful info - I appreciate it !

I have a database which creates a topic number for each new topic and once the topic is created - the new records for the same topic all bear the same topic number, for example :

Topic Created : To create an email campaign.
Topic Number : 35

Now everytime someone posts re this (35- To create an email campaign.) they use the topic code 35.

so database looks somewhat like this

Topic No. Date Remark

34 1-7-23 Started topic - assigned to x
34 2-7-23 X needs approval from Manager
35 4-7-23 To create an email campaign
35 5-7-23 Awaiting Manager Approval
35 6-7-23 Approved by manager

So I have 5 records above.

I need a report of only the two ‘latest’ records in from each field (topic no.).
So I need the following report only (of 2 records).

34 2-7-23 X needs approval from Manager
35 6-7-23 Approved by manager

Sorry I am new at this and so glad and thankful to anyone who can help.

I had noticed in another post that I can mark the new records by a marker (current=yes) and mark older records as (curent=no), i am presuming this is through a backend workflow but I dont know how to do that.,

Thanks so much in advance :slight_smile:

Hi @vijay2

Your report requirement is unusual, so you will need to be precise …

What does the ‘two’ refer to, where in the example you show only one record from each topic?

How many records will be in the table?

Thanks so much for help :
The table wil be large and will have many records.
In th enexample given there are 2 topic nos : 34 and 35, so I need only the last (latest) from each of the topics.
I will repeat the output desired and elaborate :

34 2-7-23 X needs approval from Manager
35 6-7-23 Approved by manager

Since there are 2 topics in the table / database ie 34 and 35, I want the the latest records from the 34, and 35 numbered topics

I wil add come more larger table

Data :

34 1-7-23 Started topic - assigned to x
34 2-7-23 X needs approval from Manager

35 4-7-23 Started topic To create an email campaign
35 5-7-23 Awaiting Manager Approval
35 6-7-23 Approved by manager

36 2-7-23 Started Topic X
36 4-7-23 Awaiting details from Y
36 5-7-23 Y has submitted to ABC
36 6-7-23 ABC Cleared Topic X proposal

Output :

34 2-7-23 X needs approval from Manager

35 6-7-23 Approved by manager

36 6-7-23 ABC Cleared Topic X proposal

So the above shows only the last (latest) record from each topic. IN the new example there are three topics 34,35 and 36 with varrous stages but I need output of only the latest (last date) from each topic number :slight_smile:

Hope i have made it easier and thanks a ton for all help :slight_smile:

Ideally the report would use Bubble’s list grouping function, but it is very limited.

Here is one possible way, pass the records into javascript to get filtered … Editor example runjs-last-per-topic

If it runs too slow, I’d split into batches based on topic number.

image

Thank you so much, its greatly apprecieated.

However I have no experience with Javascript and not at all confident (will try though) !

Thanks a ton and if any one knows any other way around ill be glad!

As you mentioned you can update the new record field current with yes if it is the first time you insert in database or first you search for record first in database if it not empty you get last item and make change for current to no

When you have to get data you will make do a search for record who’s current is yes

It will work in right way .

Another one you can make a new Field in database for previous item for reference previous same item this for check previous and be far form doing a search every time you do it only first time you insert new item for database

Thanks so much ! But I wanted to request you how do I make the change for older records…sorry I am a newbie so :slight_smile:

We can solve it in discord if you want
my username Abdullah2003CS

Thank you so much Amer, I solved the above, with your input and solution!
As suggested by you, I made a ‘make changes to a list of things’ (for all older records matching topic )while creating as current=no, and then added a current=yes for the current record.

Thanks a ton and really appreciate it very much!!

You’re very welcome! I’m glad I could help you with your problem.

This topic was automatically closed after 70 days. New replies are no longer allowed.