Populating a chart based on the most recent generated report id

Hi team,

I am trying to create a chart that dynamically populates the data based on the most recent report ID. For example, if a user generates reports twice, I want my chart to show data points associated with the most recent report. The below is how I structure my database,


In this example, “Date” would be my x-axis, and “Outcome” and “Predicted_outcome” would be my y-axis, all filtered by the most recent report_id.

Any help would be much appreciated!

1 Like

Hey @harry.kang.0518 :wave:

Which part are you struggling with? Are you trying to figure out how to grab the ID? Do you not know how to chart the data? Let me know. Hope we can assist. :blush:

Hey J805, I am trying to grab the most recent report_id and the associated data points for the current user.


I think I have two problems.

  1. I don’t know where to apply the filter. Do I need to filter each series’ data source directly? Or, using the conditional tab? Or, a completely different approach?
  2. I don’t know how to exactly set up the logic. I’ve tried :first item and :last item but no luck.

Can you break it down in a few simpler steps? Can you set a state on the page (on page load) that grabs the most recent report_id for them first? Then you have easier access to grab the data you need. Would that work potentially? :man_shrugging:

I am a total beginner so I haven’t explored many options yet, haha. Interacting with ChatGPT did brought up that that process but it was beyond my current knowledge. I assume you are recommending to set up a custom state on the page. How do I go about that? Can you illustrate the requires steps?

  1. On ‘page is loaded’ workflow.
  2. ‘Set state’ as the first step in the workflow
  3. Search for the users latest Report ID and save it to the custom state
  4. Use the state in the search constraints to get your data for the chart

As an alternative, you can also save the recent report id on the user when you create it in the database. Then you don’t need to use a state and can access it directly from the current user.

Does that help? :blush:

The challenge here is I don’t have the user’s latest Report ID field readily available within my “User” data type. I am generating a report ID in another platform and sending it along with other data points to my Bubble API endpoint. Can you add more context to how I could automatically append the most recent report ID to the User data type as I receive data?

Oh ok, I got it now. I think this should give your most recent report_id for your user. Or at least something close to this.

'Do a Search for Predictions' sort by date. Descending is 'yes'. first item Report_ID.

Does that make sense?