The design is as follows:
Table 1: Location List | Columns: Location Name, On Button, Off Button, Updated Date,Current Status
Table 2: Log : Location | Columns: Name, Action (either “On” or “Off” ), timestamp.
I want to have a column in Table 1 to capture the Current Status of the location, i.e. look at the newest timestamp for each location and input the value of the action in Table 2 (On,Off) to be shown. i.e. I want to display the value of the last button clicked, so whether the location was turned on or off.
I Tired using this to get the Max time Stamp in Table 2 and put it in the Updated Date Column using this if(Lookup(Log,Log.[Location Name] , [Location List].[Location Name])=[Location List].[Location Name],Max(Log.[Date and Time]),“0” )
And then use another look up in Column Current Status and match that max time stamp and Location (since the same location will appear multiple times in the log).
Instead of two separate buttons would it be better to create one column that has a drop down list of “On” or “Off” and a submit button instead that would add a row with the values I want in the Log table
I would also like to add a column to the Location List “User” to add the name of the last person that clicked on either the “On” or “Off” Button
I am still very new so any tips on how to do this would be greatly appreciated
Is there a reason you want it to be a button instead of just a toggle column type? Then you could see the On/Off status, and change it, all from one compact element.
If you did it this way, you could keep track of changes in the Log table via automations.
If you like using buttons though, one nice thing is that it makes logging easier. I’m not sure if it’s clear to you, but buttons can perform multiple actions: for example, setting the location status to On, and adding a log entry. You do this by enabling a formula in the button action, and combining multiple actions with
Not at my computer rn but it would look something like:
This is awesome, thanks for your help I love the idea of the toggle, but I couldn’t figure out how to update the Status Table with “On” or “Off” I could only do one of them. But I was able to make it to work with the buttons and updating the Status Column. I really appreciate the help!
Is there an action that would clear the values in certain cells? I added a drop down to indicate the reason for the status change and a note columns, is there a way to also delete or rest the values inside these two columns when the button is pressed?
Yeah you add more column/action pairs within ModifyRows(), and set their values to nothing, like so:
by the way, if Status is a toggle column type (or checkbox type) you can have the button “toggle” with this statement:
status, thisRow.status.Not(), which means, set status to the opposite of what it already is