Button to choose latest date/time as control value?

Hi!
I have a series of tables that I refer to through-out the day, and I only look at one row which is the entry with the latest date and time.

Currently I set the latest date with an interactive filter and a button for today and a button for yesterday, in case the latest entry was yesterday.

So there’s some guesswork involved, and also if I’ve made more than one entry today, I get more than one row for the results.

Is there a way I can create a button that will set the control value of the interactive filter to the latest date and time?

I’ve experimented with max() and Sort.Date() but have not been able to make it work.

Many thanks for any help you can offer!

FWIW, it seems like First and Last would be good options for “Select a date range” on an interactive filter for a date field?

Gregg

Hi Gregg,

Could you share some more info on what you’re trying to do?

My first thought is why don’t you just sort the table?

Hi, @Piet_Strydom …I could do that…but I am always trying to reduce distractions and eliminate unnecessary info to help maintain my focus.

I used to have a rather long form I would fill out several times a day, but I found that I sometimes make the wrong keystroke and everything I had input would disappear because I had not yet hit “Submit.”

More on this here: Anyway to Save" data on form, then keep working on it?

The new solution using views in place of a form looks like this:

Anyway, it would be nice and clean and elegant to be able to fill in the interactive filter with the last date/time entry with a button, instead of getting multiple entries for the latest date, and also having to figure out using the interactive filter dropdown if the latest entry was today or yesterday or two days ago. My thinking is that a button to populate the interactive filter with the last entry would always be a single entry without needing to know the exact date.

I hope that’s not too much information.

Gregg

Could you try to create a rowId column and then Have the button:

SetControlValue(targetControl, targetTable.filter(rowId=targetTable.rowId.max()).Date)

There’s probably a more elegant way to do it, but that would pull the largest rowId row (aka the one created most recently) and then it would pull from that row the date value you are after and input it into your canvas control.

1 Like

@Scott_Collier-Weir that’s awesome…and very elegant!

I had to make two modifications:

  1. It should start with SetControlValue vs SetControl

  2. I had to make the date column text vs Date and Time…for some reason, when the date column was designated as a Date column, the button didn’t change the value of the interactive filter. I am guessing adding Time to the Date might mess it up, since the drop down only offers date options and not time options?

Thank you!

1 Like

@Scott_Collier-Weir I just got to use the new button for real (vs testing)…it’s perfect! Thank you again!!

1 Like