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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

DAX for dynamic date reporting

@ links to members, content

 

I have tried to write a dax formula to have my report open dynamically with prior weeks data with no success. The week starts on Monday and ends on Sunday . If I run the report on 12/1/2020 the data for 11/30/2020 should show and If I run the report on 12/8/2020 the data for 12/7/2020.

 

Any help would be greatly appreciated. 

 

 Here is an example:

RegionDateSales
Central11/30/2020

2984029.0

South12/7/20208290404.0
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

According to your description, I created the data:

v-yangliu-msft_0-1608253696109.png

Here are the steps you can follow:

1. Create measure.

Measure 2 =
CALCULATE(SUM('Table'[Sales]),FILTER('Table','Table'[Date]=TODAY()-1))

2. Result.

Today is December 17, 2020, so it shows the data on December 16, 2020

v-yangliu-msft_1-1608253696110.png

You can downloaded PBIX file from here.

 

If my answer is not what you need, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

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
Anonymous
Not applicable

Hi  @Anonymous ,

According to your description, I created the data:

v-yangliu-msft_0-1608253696109.png

Here are the steps you can follow:

1. Create measure.

Measure 2 =
CALCULATE(SUM('Table'[Sales]),FILTER('Table','Table'[Date]=TODAY()-1))

2. Result.

Today is December 17, 2020, so it shows the data on December 16, 2020

v-yangliu-msft_1-1608253696110.png

You can downloaded PBIX file from here.

 

If my answer is not what you need, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

        

@ links to members, content
 
Greg I am getting error message on line with my date.  Would you please write out the DAX code.  I dont understand what you mean by filtering.  Do I add the filter in the DAX code or use the filter pane?
Greg_Deckler
Community Champion
Community Champion

@Anonymous You will need to use WEEKNUM with a second parameter of 2. You would use this in a calculated column or measure to do something like WEEKNUM(TODAY(),2), - WEEKNUM([Date],2) and you will then need to filter for current year and then this column/measure = 1



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.