Forum Discussion
Flag in Calendar
I want to build a flag (0,1) in my calendar based on,
if it is current week and monday, then add 1 to previous week dates else 0. if it is current week and >Monday then add 1 to current week.
So if today() = Current week and Monday all dates in previous week should be 1 in my flag. Tomorrow (thuesday) the flag change to 1 in current week dates, monday included, previous week dates will be 0.
I have build variables that holds start and end dates for previous and current week in my DAX but cant solve it.
Hi Stabben23 ,
Please try the column:
Flag = VAR currentDay = TODAY () VAR IsMonday = IF ( [Date] < currentDay, 1, 0 ) VAR IsNotMonday = IF ( WEEKNUM ( currentDay, 2 ) = WEEKNUM ( [Date], 2 ), 1, 0 ) RETURN IF ( WEEKDAY ( currentDay, 2 ) = 1, IsMonday, IsNotMonday )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- amitchandak
Super User
Stabben23 , not very clear, but for a month day based week you can flag like
Week Type =
var _st = today() +-1*WEEKDAY(today() ,2)+1
var _end = today() + 7-1*WEEKDAY(today(),2)
return
Switch( True(),
[Date] >= _st && [Date] <= _end ,"This Week" ,
[Date] >= _st-7 && [Date] <= _end -7,"Last Week" ,
[Week Name]
)or
Week Type =
var _st = today() +-1*WEEKDAY(today() ,2)+1
var _end = today() + 7-1*WEEKDAY(today(),2)
return
Switch( True(),
[Date] >= _st && [Date] <= _end ,1 ,
[Date] >= _st-7 && [Date] <= _end -7,0
)- Stabben23
Helper I
Thanks for answer, if I use your
Week Type =
var _st = today() +-1*WEEKDAY(today() ,2)+1
var _end = today() + 7-1*WEEKDAY(today(),2)
return
Switch( True(),
[Date] >= _st && [Date] <= _end ,0 ,
[Date] >= _st-7 && [Date] <= _end -7,1
)and change place on 1 and 0 I get what I want for now as you see in my table. But Tomorrow it should change so All 1 gets 0 and All 0 get 1 because its Thuesday, will that work dynamic?
- v-kkf-msft
Community Support
Hi Stabben23 ,
Please try the column:
Flag = VAR currentDay = TODAY () VAR IsMonday = IF ( [Date] < currentDay, 1, 0 ) VAR IsNotMonday = IF ( WEEKNUM ( currentDay, 2 ) = WEEKNUM ( [Date], 2 ), 1, 0 ) RETURN IF ( WEEKDAY ( currentDay, 2 ) = 1, IsMonday, IsNotMonday )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.