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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Need help in Dax calculation to show sales value of Current Week of Current year with last two years

Hi Community,

I need help in creating DAX Measure that calculates sales of latest week of current year i.e. 2021 then it should show the sales value of same week number of previous year i.e. 2020 and same week number for 2019 as well, let whatever the dates are for same week number doesn't matter. Refer Screenshot below:

manojbariki_87_0-1638900117177.png

Example: if Week - 50 is the current week for 2021 then when we hit Weekly button then the matrix should show the value for Week - 50 for 2020 & 2019.

 

Looking forward to your kind response

Thanks in advance!

Regards

Manoj

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can roughly understand your requirement, I think you can achieve this using some calculated columns and a measure, you can try this step:

This is the test data I created based on your description:

vrobertqmsft_0-1639122647866.png

 

Create two calculated columns:

Week = "Week - "&WEEKNUM('Table'[Date])
Year = YEAR('Table'[Date])

Create a measure:

Measure = SUM('Table'[Amount])

 

And you can create a matrix and a slicer to place them liks this to get what you want:

vrobertqmsft_1-1639122647872.png

 

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can roughly understand your requirement, I think you can achieve this using some calculated columns and a measure, you can try this step:

This is the test data I created based on your description:

vrobertqmsft_0-1639122647866.png

 

Create two calculated columns:

Week = "Week - "&WEEKNUM('Table'[Date])
Year = YEAR('Table'[Date])

Create a measure:

Measure = SUM('Table'[Amount])

 

And you can create a matrix and a slicer to place them liks this to get what you want:

vrobertqmsft_1-1639122647872.png

 

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @Anonymous 

 

Do you have a Calendar [Date] table in your model? If not, sue this link to add it to your model:

https://www.vahiddm.com/post/creating-calendar-table-with-3-steps

 

then you can use the Week No. column in the Rows and Year in the columns and add value to the Matrix.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

bcdobbs
Community Champion
Community Champion

I don't think you need any fancy DAX for this although may be missing a requirement.

 

What you need is a date table which has the following columns: Date, Week Number, Year.

 

A relationship from date to date on your sales table will be one to many.

 

Then on a matrix you can drop Week Number on the rows and year on the columns.

Lots of ways of creating a date table but you could start here: Creating a simple date table in DAX - SQLBI



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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