Forum Discussion

koorosh's avatar
koorosh
Icon for Post Partisan rankPost Partisan
3 years ago

Last week sales

Hello all, please complete or correct my DAX expression for the following expression:

If today is Saturday calculate total sales between 5 days ago and 1 day ago from today.

 

TotalSalesLastWeek = IF('Date'[Todayofweek] = "Sat",
CALCULATE(sum(Sales[Sales$]),
DATESINPERIOD(('Date'[Date],([Todayofweek]-1),-5,day),
.....................

Meanwhile, how can I do the above expression with Switch and SelectValue?

7 Replies

  • Hi,

    The general pattern is as follows:

    =calculate(sum(Sales[Sales$]),datesbetween('Date'[Date],min(calendar[date])-5,min(calendar[date])-1))

    • koorosh's avatar
      koorosh
      Icon for Post Partisan rankPost Partisan

      Hi Ashish, we want date between 5 days earlier today and 1 day earlier today. Why you used min expression?

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Icon for Super User rankSuper User

        Because i want to capture the value of the Date.  I assume that you have dragged date (from the Calendar table) to the Table visual

  • koorosh's avatar
    koorosh
    Icon for Post Partisan rankPost Partisan

    Despite of what is today, I want the total minutes (or total sales for other popular sales data) for the last Monday to the next's Sunday.

    Also, if I select a date by date slicer, the total for its previous Monday to next's Sunday.

    • koorosh's avatar
      koorosh
      Icon for Post Partisan rankPost Partisan

      Total for the week based on the selected date by date slicer