Forum Discussion
Dax for Current Week & Previous Week
- 5 years ago
You could add a variable to calculate the most recent monday (relative to the MAX date), and then calculate your measure between the max date and that Monday date.
Weekly =
VAR _selectedDate =
MAX ( Table1[DayDate] )
VAR _endOfWeekDate =
_selectedDate + 7
- WEEKDAY ( _selectedDate, 2 )
VAR lastMonday =
CALCULATE (
MAX ( Table1[DayDate] ),
FILTER (
ALL ( Table1[DayDate] ),
Table1[DayDate] <= _selecteddate
&& WEEKDAY ( Table1[DayDate] ) = 2
)
)
RETURN
CALCULATE (
SUM ( Table1[TH] ),
FILTER (
ALL ( Table1[DayDate] ),
Table1[DayDate] <= _endOfWeekDate
&& Table1[DayDate] >= lastMonday
)
)Pat
Hi Anonymous ,
Is the understanding of your requirements below correct?
User selection is Today = current week data until today
User selection higher than today = data from today until the day selected
User selection lower than today = full week of the day selected
Just a couple of questions how do you handle the selection of a day of the current week but lower than today? (do you pick up all the values of the week or only the ones until today or the selected day?
Are you abble to choose values after the current week? for example august date what values will you get for that selection?
Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.
If the information is sensitive please share it trough private message.
- Anonymous5 years agoNot applicable
Hi MFelix Apologies for late reply. Thanks for your response.
Hi Pat mahoneypat . Thanks so much my issue resolve with your code and have done little bit changes as per the requeirement.
Regards,
PV