Extract date-ranges from a list of dates

well…

turns out client expresses even single-day availability as D1…D1

however…

i have modified the formula to report a single-day availability is just a single date
as it makes more sense in general

so i changed the final formula for the Available column as follows…

Sequence(1,thisRow.Ranges.Count()-1,2).FormulaMap(       // loop over every PAIR of dates in Ranges
  CurrentValue.WithName(D,                               // indexing with D
    Concatenate(
      thisRow.Ranges.Nth(D),				             // show the 1st date
      SwitchIf(
        thisRow.Ranges.Nth(D)!=thisRow.Ranges.Nth(D+1),  // if 1st date & 2nd date are different
        Concatenate('...',thisRow.Ranges.Nth(D+1))       // show ... 2nd date
      )
    )
  )
).BulletedList()                                         // present the resulting list as bullets

thanks @Christiaan_Huizer for pointing out this improvement

as you pointed out, i tend to use SwitchIf() instead of If()
whenever i only want to specify a result for the TRUE condition
because SwitchIf() allows me to leave out the FALSE action
whereas the If() requires me to specify the FALSE action as well, even if its ‘do nothing’

max

3 Likes