Count days of a checked checkbox

Hello everybody!

I’ve facing a problem for a long time so I’m trying to bring it here so someone can help me.

I’ve a app that a user controls itens of an inventory. The iten of the inventory can receive any of this options below within a month.

So, when the user selects one of this, the iten in inventory register that is in this new condition (In this case I added “VNI” and “PAI” to the iten).


When the option is not necessary anymore, the user removes the option from the item, and each option can be used for a different amount of days.

I’ve to control how many days each item was using the option selected, separadely. I’ve to see how many days the iten was using “VNI” and how many days the iten was using “PAI” in my example above.

Can anyone here please help?


If I understand this correctly, you wish to track how much time an item has VNI or PAI used - or any other choice.

Possible solution: The key is to have a separate log file that holds the time information that can be related back to the inventory item. You are not trying to track the state but rather the time! Hence, use time as the underlying data element.

Create a new table called ItemLog (for example) with the fields StartDate, Inventory Item ID, Attribute Type). You can use an Option Set to hold the Attribute IDs since they are constants and then link to them. This should be the text labels CVC, SVD… …DVA. This will allow you to simplify the user interface by combining the label name and checkbox function (removing the checkbox icon but retaining the text information).

  1. Do not use a logical field to indicate the state - use a Date field to replace the checkboxes. In your example you will need 11 in the record.
  2. (a) If the date is empty then the corresponding element color indicates the state using a condition set on the element. (background none, with a border, normal text)
  3. (b) If the date is not empty then the corresponding change the color to the opposite effect using a condition set on the element (background solid, with a border, white text).
  4. (a) Each time the user clicks on the checkbox execute a workflow it sets the date (updates the inventory record) of the corresponding field to the Current Time/Date [ if empty ]
  5. (b) If the date is not empty then two steps - create a record in the Item Log with the ID of the inventory Item, the reference to the attribute (VNI, PAI ect) and the date value previously stored when from the inventory table. Then, clear the date in this inventory table to turn of the indicator.

You will now have an ongoing log of each time the attribute (VNI… ect) was first check and then unchecked. The checked time of VNI is found by ItemLog->CreateDate - StartDate. You can also use the Create date to do Grouping for calculations related to per Day, Per Month, ect… and also cross reference Items, or just a specific Item. Finally, you also have a record of when an item was check if it remains checked, because it is stored in the inventory record.

Hope this is helpful and I was not too confusing with my explanation, if other members have a better solution I love to learn.
Regards, John

@jgellis , thanks for your answer!

I’m not quite sure if i understand all your explanation, sorry.

Currently I’ve these data types “paciente” and “dispositivo (list of dispositivoes)” like this:


WHen I select a “dispositivo” from the checkbox group, the app change the thing (“paciente”) and add a dispositivo to this.

The iten is showing the “VNI” to the user like:


You are suggesting that I shoud not have it as a List of Dispositivoes and instead use a new data type called ItemLog? Is that right? I’ve never worked with log before…

Sorry to bother you again :sweat_smile:

Hi, no worries. Maybe I do not understand, so sorry I need to ask. Are you attempting to track physical inventory of objects? I am guessing that you are attempting to track which patients have a specific device and for how long. (Sorry I think you are working in Portuguese? so I am translating).

Exactly I basically plug a device (dispositivo) into an item (paciente) in my inventory. I need to know how long this device has been connected to a particular stock item.

Eg. The paciente X was using the devide VNI for 4 days.

OK, Great…

You need a List of Dispositivoes and you need another list which is the logbook (diário de bordo) hope that is right.

Give me a few minutes and I will do a picture…


Eg. Paciente X used VNI for 4 days and VM for 8 days
Paciente Y used SNM for 2 days and O2 for 3 days and VNI for 10 days

And so on :sweat_smile:

Q. Do you only have 1 of each type of device? Or, do you have many of each type of device?

1 of each type. 1 VNI, 1 VM, …

OK thanks


The device table stores the date that the device was checked out, until it is checked back in. The table also holds the link to the Patient that has it.

When the device is returned the date is copied to the DeviceTimeLog table along with the link to the patient that had it. Then the date in the device table and the patient link are deleted making the fields empty again ready for a new date and a new patient.

The time log holds the history of the use of the device.

The screen shows the status of the device by looking at the date field in the Device table. If the date field is empty the device is available, if the date field is not empty the device is already assigned to a patient and not been returned.

Since the device table holds the date the device was checked out and the patient link you can tell if the device is overdue for return.

The TimeLog table holds all the information on when the device was use, who used it, how long they had it, and the number of times it was use.

Hope this is better. :slight_smile:


Please note… this only works if you only have one device of each type. If you ever will have more than one of each type this data model will not work well. Please keep this in mind.

For you buttons you can use a Repeating Group and use the Type field from the Device table. This will simplify the workflow since you can use the Parent Element feature of bubble in the workflow when the user clicks the button. And, populate the text on the button from the Type field.

Sorry to ramble – hope this help.

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