(update) Hi all
is it possible to create a dynamic sequence for the number of weeks based on the current month?
which I then want to use for a drop-down/combo box control (Collection as item?)
currently using
"Week " & RoundDown(
(Day(Today()) - Day(DateValue("1/1/" & Year(Today()))) + Weekday(DateValue("1/1/" & Year(Today())) - 1)) / 7,
0
) + 1
on a text label which just gives the current week number for the current month (this gives correct week)
Issue:
ClearCollect(
AvailableWeeks,
AddColumns(
Sequence(
RoundUp(
(Day(
DateAdd(
Date(
Year(Today()),
Month(Today()) + 1,
1
),
-1,
TimeUnit.Days
)
) -// Last day of the current month
Day(
Date(
Year(Today()),
Month(Today()),
1
)
) + 1 +// Day of the first day of the current month
Weekday(
Date(
Year(Today()),
Month(Today()),
1
) - Day(
Date(
Year(Today()),
Month(Today()),
1
)
) + 1
)// Weekday of the first day of the current month
) / 7,
0
)
),
"WeekNumber",
"Week " & Value
)
);
this gives 5 weeks which is wrong as February has 4 weeks
any suggestion would be great
thank you 😃
@LEGRANCHE Woww! Thank you so much 😀
did not even have to use clear collect ,learn something new every day
this works perfect for my items
With(
{StartDate: Date(Year(Today()), Month(Today()), 1)},
AddColumns(
Filter(
[1, 2, 3, 4, 5, 6],
Value < 1 + ISOWeekNum(DateAdd(StartDate, 1, TimeUnit.Months)) - ISOWeekNum(StartDate)
),
"WeekNumber",
"Week " & Text(Value)
)
)
Hi
to get the number of weeks within the current month, you can use the following:
With(
{StartDate:Date(Year(Today()), Month(Today()),1)},
ISOWeekNum(DateAdd(StartDate,1,TimeUnit.Months))-ISOWeekNum(StartDate)
)
Now to use it for the property items of drop-down, use the following:
With(
{StartDate:Date(Year(Today()), Month(Today()),1)},
Filter([1,2,3,4,5,6],Value<1+ISOWeekNum(DateAdd(StartDate,1,TimeUnit.Months))-ISOWeekNum(StartDate))
)
Let me know if my answer helped solving your issue.
If it did please accept as solution and give it a thumbs up so we can help others in the community.
WarrenBelz
89
Most Valuable Professional
MS.Ragavendar
60
stampcoin
48