Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
koorosh
Post Partisan
Post Partisan

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 7
koorosh
Post Partisan
Post 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.

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

 

koorosh_0-1682235053290.png

 

Ashish_Mathur
Super User
Super User

Hi,

The general pattern is as follows:

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


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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

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


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

What is the output of the min(calendar[date]? Would it be today?

No.  Assuming you have dragged dates from the Calendar Table to the Table visual, it will simply give the Date value.  The MIN() can be replaced with MAX as well.  You may want to share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.