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
harirao
Post Prodigy
Post Prodigy

Creating Trend comparing current week with previous week

Hi Team,

Required assistance, I am trying to create weekly trend comparing current wk vs previous week, used below dax  but not getting correct result
Colum:

PreviousReportDate = DATEADD(Query1[reportdate],-7,DAY)

Measure, highlighted in red is also measure 
Trend =
CALCULATE([%6week_1&2], FILTER(ALL(Query1),Query1[reportdate]=SELECTEDVALUE(Query1[PreviousReportDate]) && Query1[subregion]=SELECTEDVALUE(Query1[subregion])))

Below is screen print where Trend suppose to get 18th data but getting incorrect result 
25th  Data25th Data

18th 
18th Data18th Data
Once i get correct result for Trend i can create new Measure as per below comparison.
3.PNG


Regards,
Hari
 




2 ACCEPTED SOLUTIONS
AllisonKennedy
Super User
Super User

@harirao  I'm assuming you have a DimDate table?? 

 

If not, get one, they make a big difference:

https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html

 

Once you have the date table, I would consider a slightly different approach to this problem, using time intelligence to change the filter context within the measure, rather than creating a calculated column for previous period. 

 

So something like: 

 

Trend =
CALCULATE([%6week_1&2], DATEADD(DimDate[Date], -7, DAY))
 
No need to mess with region as that will come automatically from the context of the matrix. 
 
@harirao  A small update:
In the slicer, either use the:
DimDate[Date] ,
DimDate[ReportWeek]
DimDate[Week]
 
Basically anything from the DimDate table NOT the Query1[reportdate]

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

amitchandak
Super User
Super User

@harirao , refer to my blog on how to work with the week; this week vs last week etc.

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

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/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

 

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

2 REPLIES 2
amitchandak
Super User
Super User

@harirao , refer to my blog on how to work with the week; this week vs last week etc.

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

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/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

 

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
AllisonKennedy
Super User
Super User

@harirao  I'm assuming you have a DimDate table?? 

 

If not, get one, they make a big difference:

https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html

 

Once you have the date table, I would consider a slightly different approach to this problem, using time intelligence to change the filter context within the measure, rather than creating a calculated column for previous period. 

 

So something like: 

 

Trend =
CALCULATE([%6week_1&2], DATEADD(DimDate[Date], -7, DAY))
 
No need to mess with region as that will come automatically from the context of the matrix. 
 
@harirao  A small update:
In the slicer, either use the:
DimDate[Date] ,
DimDate[ReportWeek]
DimDate[Week]
 
Basically anything from the DimDate table NOT the Query1[reportdate]

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.