Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
Need to find dynamically changing week i.e., need to display previous week(sales) vs current week(sales) against fiscal year.
Hi @PavithraShan,
For your requirement, you can use year and weeknum to find out correspond week to calculate:
If you confused about coding formula, can you share some dummy data to help us clarify your data structure and test?
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
If you have a date table and week slicer coming from that you can have 7 days behind measure to give you last week
last week Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-7,Day)))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
Then how to calculate Current week sales? Is That change dynamically for upcoming weeks?
Check if this can help
This week sales =
var _date = date(year(today()),month(today()),day(today()))
var _Week_ED = _date + (-1*WEEKDAY(_date)+1)
var _Week_SD= _date +(7-1*WEEKDAY(_date))
Return
CALCULATE(sum(Sales[Sales Amount]),all('Date'),Sales[Sales Date]>=_Week_SD && Sales[Sales Date]<=_Week_ED)
Last week sales =
var _date = date(year(today()),month(today()),day(today()))
var _Week_ED = _date +( (-1*WEEKDAY(_date)+1)-7)
var _Week_SD= _date +((7-1*WEEKDAY(_date))-7)
Return
CALCULATE(sum(Sales[Sales Amount]),all('Date'),Sales[Sales Date]>=_Week_SD && Sales[Sales Date]<=_Week_ED)
Isnt that formula just gonna give him - 7 days so it can be between weeks depending on what day it is today?
I mean week 52 is 52 not half 51 & half 52
/Adam
Try like
This WEEK
var _max_week = maxx(date,date[Fiscal Week])
return
calculate(sum(x),all(date[Fiscal Week]), Date[Fiscal Week] =_max_week)
last week
var _last_week = calculate(Max(Fiscal Week),datediff(date[date],-7,day))//
return
calculate(sum(x),all(date[Fiscal Week]), Date[Fiscal Week] =_last_week)
I
Hi,
you can add a custom Column in powerquery to your calendar:
for example for previous week.
= Table.AddColumn(#"YourPreviousStep", "LastWeek", each if Date.IsInPreviousWeek([Date]) then "Yes" else "No")
and then you can you can build your measure with filter on those columns
/Adam
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 130 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |