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
ydundar
Frequent Visitor

how to get 3 months before measured date

Hi,

I created and formatted a date by sending  values 

DATE(YEAR(TODAY()), SELECTEDVALUE(Months[Month], MONTH(TODAY())),1) as measure.
 
I want to get 3 months before this calculated date. But I couldn't use DATEADD function because it doesn't accept a measure as date parameter. So what else can I do? Thanks in advance.
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @ydundar 

What's result do you want?

 

Method 1:

get a sum values in the past three months of the selected date

Create two tables

calendar = CALENDARAUTO()

filter table = ADDCOLUMNS(CALENDARAUTO(),"year",YEAR([Date]),"month",MONTH([Date]))

Capture23.JPG

Create measures

selected date = DATE(YEAR(TODAY()),SELECTEDVALUE('filter table'[month],MONTH(TODAY())),1)

Measure = CALCULATE(SUM('Table'[value]),DATESINPERIOD('calendar'[Date],[selected date],-3,MONTH))

Capture24.JPG

Method 2:

Get a table (for selected date 2019/9/1, table show date from 2019/6/2~2019/9/1)

Table 2 = DATESINPERIOD('calendar'[Date],[selected date],-3,MONTH)

 

Best Regards Maggie

Community Support Team _ Maggie Li

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

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @ydundar 

What's result do you want?

 

Method 1:

get a sum values in the past three months of the selected date

Create two tables

calendar = CALENDARAUTO()

filter table = ADDCOLUMNS(CALENDARAUTO(),"year",YEAR([Date]),"month",MONTH([Date]))

Capture23.JPG

Create measures

selected date = DATE(YEAR(TODAY()),SELECTEDVALUE('filter table'[month],MONTH(TODAY())),1)

Measure = CALCULATE(SUM('Table'[value]),DATESINPERIOD('calendar'[Date],[selected date],-3,MONTH))

Capture24.JPG

Method 2:

Get a table (for selected date 2019/9/1, table show date from 2019/6/2~2019/9/1)

Table 2 = DATESINPERIOD('calendar'[Date],[selected date],-3,MONTH)

 

Best Regards Maggie

Community Support Team _ Maggie Li

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

Thanks @v-juanli-msft. That was so helpful.

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.