Forum Discussion

Sander1401's avatar
Sander1401
Icon for Helper II rankHelper II
2 years ago
Solved

Last Sunday in dataset

Hi all,

is there a way to calculate (DAX) the last Sunday of the dataset?

for example if the max date in the dataset is Monday 15-04-2024, I would like the date 14-04-2024. If the max date is 14-04-2024, then I would also like 14-04-2024.

 

Sander

4 Replies

  • ahoggatt42's avatar
    ahoggatt42
    Regular Visitor

    Have you tried a measure:

     

    Test = CALCULATE(LASTDATE(*Date*),WEEKDAY(*Date*,1)=1)
    • Sander1401's avatar
      Sander1401
      Icon for Helper II rankHelper II

      I will definitely try this one, thanks. 
      my own solution (not tested yet) is:


      If (weekday(Max date, 2) = 7, max date, max date - weekday(Max date, 2))

       

      but yours looks more clear.

  • you need to create a column in the calendar table

  • Simple enough,

    But bear in mind, this measure is single-purposed and used only by itself.