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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nshindel
Frequent Visitor

Advanced Editor - Date Editor - From today, look 13 full months back

Hi - I am using M in the advanced editor to try and make a dynamic date range. Ideally, I would like to go back 13 months from today's date, but just at the month level.

 

For example, today is May 28th, 2019, I want the date range to be April 1, 2018 - May 28 2019, and on June 1st, the date would change to May 1 2018 - June 1 2019, etc, etc. I cannot figure out the syntax.

2019-05-28_11-31-58.png

3 REPLIES 3
jeffshieldsdev
Solution Sage
Solution Sage

Use Date.StartOfMonth and Date.AddMonths

 

Date.AddMonths(Date.StartOfMonth(Date.From(DateTime.LocalNow())), -13)

 

 

PedroReis
Advocate II
Advocate II

Hi,

 

Which data source are you using? Don't you have a Date Dimension? Then it's very simple with SQL.


Select * from DIM_DATE

WHERE date >= select dateadd(mm, datediff(mm, 0, @ThisDate) - 13, 0)  -- Beginning of 13 months ago

Hi - This is not in SQL. I am actually connecting through the Adobe Analytics API, so it has to be done in the Advanced Editor.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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