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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
buttercream
Helper I
Helper I

Week vs prior week in visual based on slicer selection

I have a visual showing number of orders.  I would like to break this up by last 7 days vs prior last 7 days (this week vs last week).  However, I'd like to start the week's count based on the date chosen in the slicer.

 

Example:

User selects 'Feb 5 2025' in slicer.  My bar graph visual should show two bars.  One with Feb 19-25 (week 1) and Feb 12-18 (Week 2).

 

How to accomplish?

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@buttercream , You can not accomplish a trend based on that,

 

You can have measures

Last week =
var _max = maxx(ALLSELECTED('Date'[Date]),'Date'[Date] ) -1
Var _min = Max -6
return
calculate([measure], filter(all('Date'), 'Date'[Date] >= _min && 'Date'[Date] <= _max))

 

Next Week=
var _max = maxx(ALLSELECTED('Date'[Date]),'Date'[Date] ) +7
Var _min = Max +1
return
calculate([measure], filter(all('Date'), 'Date'[Date] >= _min && 'Date'[Date] <= _max))

 

same way you can calculate dates to display on labels

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Try this approach

  1. Create a Calendar table
  2. Create a relationship (Many to One and Single) from the Date column of your fact table to the Date column of the Calendar table
  3. To your visual/table/slicer/filter, drag date from the Calendar table and select a date there
  4. Write these measure

Total = sum(Data[Amount])

Total in this week = calculate([total],datesbetween(calendar[date],min(calendar[date])-6,min(calendar[date])))

Total in previous week = calculate([Total in this week],

datesbetween(calendar[date],min(calendar[date])-6,min(calendar[date])))

Hope this helps.


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

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @buttercream,

 

Thanks @Ashish_Mathur  and @amitchandak for Addressing the issue.

 

we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Regards,
Vinay Pabbu

Anonymous
Not applicable

Hi @buttercream,

 

we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Regards,
Vinay Pabbu

Anonymous
Not applicable

Hi @buttercream,

 

we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Regards,
Vinay Pabbu

Ashish_Mathur
Super User
Super User

Hi,

Try this approach

  1. Create a Calendar table
  2. Create a relationship (Many to One and Single) from the Date column of your fact table to the Date column of the Calendar table
  3. To your visual/table/slicer/filter, drag date from the Calendar table and select a date there
  4. Write these measure

Total = sum(Data[Amount])

Total in this week = calculate([total],datesbetween(calendar[date],min(calendar[date])-6,min(calendar[date])))

Total in previous week = calculate([Total in this week],

datesbetween(calendar[date],min(calendar[date])-6,min(calendar[date])))

Hope this helps.


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

@buttercream , You can not accomplish a trend based on that,

 

You can have measures

Last week =
var _max = maxx(ALLSELECTED('Date'[Date]),'Date'[Date] ) -1
Var _min = Max -6
return
calculate([measure], filter(all('Date'), 'Date'[Date] >= _min && 'Date'[Date] <= _max))

 

Next Week=
var _max = maxx(ALLSELECTED('Date'[Date]),'Date'[Date] ) +7
Var _min = Max +1
return
calculate([measure], filter(all('Date'), 'Date'[Date] >= _min && 'Date'[Date] <= _max))

 

same way you can calculate dates to display on labels

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.