Sequence foreach worker

Hi guys. I’m currently trying to do something i’ve felt kinda complex.
I’m doing a work calendar for a business. I’ve done a button that, given two dates, it generates one row for each day between those dates for the selected worker.
The problem is, right now it’s only 12 workers, but if it increases, it may get annoying to do. Does anyone know how to use foreach with the sequencer i made so it does generate those rows for each worker? Screenshots here:

Fecha inicio means starting date and Fecha Final means ending date.

Here, you can see how it works. Date 1, date 2 and worker (which points towards a table with the workers) and a button for it to generate.

Thanks for anyone willing to help!

Hi @Pedro_Jimenez :blush: !

You’re not that far from getting your desired result :grin: !
Here’s the formula I used in the quickly made sample you’ll find below :blush: :

  // For each selected worker in [Select Workers] ...
  // (Each specific worker in that list being represented by CurrentValue)
  [Select Workers].ForEach(
    // Store its CurrentValue in the list within the value W so 
    // we can use it later.
      // Then, for each date in the sequence, add a row ... 
      Sequence(Start,End + 1).ForEach(
          W, // The "Current worker" in the list 
  [Select Workers].ResetControlValue()

As you can see, you would need to use 2 nested ForEach() (/FormulaMap()) :

The 1st one acts on each specific worker selected in the canvas control and stores its specific value within W (WithName()).
This is done so each specific worker can be referenced within the nested and 2nd ForEach() acting on the sequence of date, like you already did (as in this case, CurrentValue is each specific date within the sequence) :blush: .

I left you, as an example, a canvas formula re-creating the list of lists of values the button uses when adding rows to the table, hoping this would help you visualise its action a little bit better :blush:

I hope this helps a little :innocent:


Hi @Pch
It worked great, thanks!

My pleasure @Pedro_Jimenez :grin: !
Glad to know this helped you :grin: !

Hi (buenas tardes),
Would like to ask you how do you do to have those colored borders around your “Fecha inicio”, “Fecha Final”, “Trabajador” ?
I’m trying since days to have forms fields grouped into rectangular spaces too but didn’t see how to do so…
I see your table sems to be surrounded by a rectangular colored lines too…


Any relation with Harry Potter family?



Hi @Anthony_Fernandez_Ferrandiz
I did nothing to color the borders, it’s just the Coda UI designed to color them whenever ur seeing a formula! Look, “Fecha Inicio” is green, in the formula and the border, same with the other fields! I hope some day we can change the color of the borders, but this is not possible yet :grin:

I know how to do it too…
Learnt it the first year in Poudlard!

¡Qué tonto soy!

Thank you


1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.