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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.