Indeed a wonderful contribution dear @Agile_Dynamics .
I took the freedom to create the inverse of your list, thus following the same logic to see the still available ranges (or dates since they follow a comparable logic).
I defined 4 steps. Below how it goes. I started with creation of a list of missing numbers and named it step 01. If you are new, the function Max() is not related to ‘Max’
Sequence(1,daysText.Split(",").Max()).Filter(CurrentValue.Contains(daysText.Split(",")).Not())
In step02 I make use of step01 and as you can see I changed two things. I replaced the SwitchIf for an If statement. However this is not a very good choice, the SwitchIf permits you to continue without expressing the case for if not. When you use an If statement, you need to tell what happens in case the condition is not met. In this case nothing so " ". This works, but is not very smart.
The second difference is the use of Concatenate() instead of the + , I Both work fine, it is mainly a matter of preference and habit I guess.
Sequence(2,Step01.Count()).FormulaMap(
CurrentValue.WithName(I,
If(Step01.Nth(I)-Step01.Nth(I-1)>1,
Concatenate(Step01.Nth(I-1),"-",Step01.Nth(I)),""
)
)
).Filter(CurrentValue)
I continue with the SwitchIf below, it is the better choice:
ListCombine(
Step01.First(),
step02.FormulaMap(
CurrentValue.SwitchIf(
CurrentValue.Split('-'))
),Step01.Last())
And we finish with the last step I shortened a bit by not using WithName()
, this is a perso pref in this context, both work fine.
Sequence(1, step03.Count() - 1)
.FormulaMap(
step03.Nth(CurrentValue) + '-' +
step03.Nth(CurrentValue + 1)
)
What a wonderful exercise with a method that can be applied in so many docs, Merci @Agile_Dynamics