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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
rob_mysbxsec
Helper II
Helper II

measure dax and table view m-code scoping results to created_date in the last 30 days

Using a report page's Filters on this visual / page / all pages | created_date | filter type = Relative Date | Show items when the value = is in the last 30 days configuration its very straight forward to create views based on past 30 days.

 

That said what's the recommended syntax for creating . . . 

 

1) A measure [ / statistic / fact ] value using dax syntax to compute something based on created_date is in the last 30 days from todays date? 

 

2)  A model | transform data | copy of existing table with m-code that limits table records to those where created_date is in the last 30 days from todays date?

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

HI @rob_mysbxsec,

#1, You can create a measure extract the current date and manually calculate the previous date to filter on your tables. For extract value operations, you can use selectedvalue(all types of values and not suitable to handle multiple selections) or other aggregate functions(suitable for numeric value for date values).

Using the SELECTEDVALUE function in DAX 

#2, You can add a filter on your date field to filter the range of records, please take a look at the following links to know more about the operations:

PowerQuery Dynamic Date Dimension Table Filtering 

Power Query Current Date Filter 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @rob_mysbxsec,

#1, You can create a measure extract the current date and manually calculate the previous date to filter on your tables. For extract value operations, you can use selectedvalue(all types of values and not suitable to handle multiple selections) or other aggregate functions(suitable for numeric value for date values).

Using the SELECTEDVALUE function in DAX 

#2, You can add a filter on your date field to filter the range of records, please take a look at the following links to know more about the operations:

PowerQuery Dynamic Date Dimension Table Filtering 

Power Query Current Date Filter 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@rob_mysbxsec , On way is to use relative date slicer and limit the data on page for last 30 Days.

 

Another is have a measure like this with help from date table

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],today(),-30,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 :radacad sqlbi My Video Series Appreciate your Kudos.

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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