Solved! Go to Solution.
Hi @DevadathanK ,
I'm so glad to meet your issue again.
Since I've answered your last post, let me started from my previous reply.
Actually, you just need to make a little change from my previous reply.
The previous reply:
Filter(b,Value>=startweek,Value<=endweek)
//get current week num
Try this formula instead:
AddColumns(
AddColumns(
AddColumns(Filter(b,Value>=startweek,Value<=endweek),
"id",
Value-First(Filter(b,Value>=startweek,Value<=endweek)).Value
), //get the id value based on weeknum
"startdate",
DateAdd(Date(Year(Today()),Month(Today()),1),7*id,Days)
), //get the start date based on id
"enddate",
DateAdd(startdate,6,Days) //get end date based on start date
)
Other steps are the same.
Best regards,
Hi @DevadathanK ,
I can start you on this and happy to help if you get stuck.
Firstly the formula (assuming DatePicker1 is your data source) for the current day of the year would be
DateDiff(
Date(
Year(DatePicker1.SelectedDate),
1,
1
),
DatePicker1.SelectedDate
) + 1
The week number of the date would be
Round(
(
DateDiff(
Date(
Year(DatePicker1.SelectedDate),
1,
1
),
DatePicker1.SelectedDate
) + 1
)/7,0
)
You can get the day of the week with
Weekday(DatePicker1.SelectedDate)
So the start of the week date is
DatePicker1.SelectedDate - Weekday(DatePicker1.SelectedDate) +1
Please let me know how you go with this.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Thanks @DevadathanK ,
That is why I gave you all the formulas - I was not sure how you were doing it. I am not sure how you would reverse engineer the one from the date to the date number, but you could simply collect the 52 possibilities as below at App OnStart and do a Lookup.
ClearCollect(
colWeekNos,
{
WeekNo: 1,
WeekStart: DateValue("1/1/2020")
},
{
WeekNo: 2,
WeekStart: DateValue("1/8/2020")
},
{
WeekNo: 3,
WeekStart: DateValue("1/15/2020")
},
{
WeekNo: 4,
WeekStart: DateValue("1/22/2020")
},
{
WeekNo: 5,
WeekStart: DateValue("1/29/2020")
}
)
Then
Lookup(
colWeekNos,
WeekNo = Value(YourTextBox.Text),
WeekStart
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @DevadathanK ,
I'm so glad to meet your issue again.
Since I've answered your last post, let me started from my previous reply.
Actually, you just need to make a little change from my previous reply.
The previous reply:
Filter(b,Value>=startweek,Value<=endweek)
//get current week num
Try this formula instead:
AddColumns(
AddColumns(
AddColumns(Filter(b,Value>=startweek,Value<=endweek),
"id",
Value-First(Filter(b,Value>=startweek,Value<=endweek)).Value
), //get the id value based on weeknum
"startdate",
DateAdd(Date(Year(Today()),Month(Today()),1),7*id,Days)
), //get the start date based on id
"enddate",
DateAdd(startdate,6,Days) //get end date based on start date
)
Other steps are the same.
Best regards,
Hi @DevadathanK ,
The response from code guru @v-yutliu-msft is certainly more elegant than mine - tag me if if you want to continue with my logic.
Hello @v-yutliu-msft what if I want to display all the weeks of the year? is it possible?
Thank you.
User | Count |
---|---|
256 | |
107 | |
90 | |
51 | |
44 |