
Hello everyone,
My need is to build a dropdown list with the last 52 weeks from the current week.
To do this I build a collection with a 'WeekStart' column like below :
Set(currentMonday,DateAdd(Today(),1-Weekday(Today(),StartOfWeek.Monday),TimeUnit.Days));
ClearCollect(tempweekscol,
ForAll(Sequence(52,-51,1) As DD,
{
WeekStart: DateAdd(currentMonday,7 * DD.Value ,TimeUnit.Days)
}));
But now I am blocked I need to add new columns to this collection.
One column named WeekEnd with Friday's List value : DateAdd(ThisRecord.WeekStart,4,TimeUnit.Days)
and
One column named WeekDisplay with Text value : Text(ThisRecord.WeekStart)&" - "&Text(ThisRecord.WeekEnd)
I tried do addcolumn :
Collect(weekscol,AddColumns(weekscol,"WeekEnd",DateAdd(ThisRecord.WeekStart,4,TimeUnit.Days),"WeekDisplay",Text(ThisRecord.WeekStart)&" - "&Text(ThisRecord.WeekEnd)))
but this formula doesn't work. In my opinion, my problem is linked to "ThisRecord.WeekStart" I don't know how I can call each item of my column to calculate others columns.
Thank you for your answer
Hi @Ez_ ,
Please try:
Set(currentMonday,DateAdd(Today(),1-Weekday(Today(),StartOfWeek.Monday),TimeUnit.Days));
ClearCollect(tempweekscol,
ForAll(Sequence(52,-51,1) As DD,
With(
{WeekStartData:DateAdd(currentMonday,7 * DD.Value ,TimeUnit.Days),WeekEndData:DateAdd(currentMonday,7 * DD.Value+4 ,TimeUnit.Days)},
{
WeekStart: WeekStartData,
WeekEnd: WeekEndData,
WeekDisplay:WeekStartData&"-"&WeekEndData
}
)
)
);
Best Regards,
Bof