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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Caldowd98
Helper I
Helper I

DATESINPERIOD Function

Hi Community

 

Im using the Datesinperiod funtion will the below DAX formula, however it doesnt seem to work with the filter in.

 

Any ideas ?

 

Many Thanks !

 

LTM Brand 1 = CALCULATE(SUM('Sheet1'[Quantity]), FILTER(Sheet1,Sheet1[Type]= "Brand 1" && DATESINPERIOD( Sheet1[Date].[Date], MAX( Sheet1[Date] ), -12, MONTH )))
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Caldowd98 ,

Here are the steps you can follow:

1. Create measure.

Measure =
CALCULATE(SUM('Sheet1'[Quantity]),FILTER(ALLSELECTED('Sheet1'),'Sheet1'[Type]="Brand 1"&&'Sheet1'[Date]>=DATE(YEAR(MAX('Sheet1'[Date]))-1,MONTH(MAX('Sheet1'[Date])),DAY(MAX('Sheet1'[Date])))&&'Sheet1'[Date]<=MAX('Sheet1'[Date])))

2. Result:

vyangliumsft_0-1643177088325.png

Will vary with the filter: say, filter out October 2021, and the result will vary

vyangliumsft_1-1643177088329.png

 

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  @Caldowd98 ,

Here are the steps you can follow:

1. Create measure.

Measure =
CALCULATE(SUM('Sheet1'[Quantity]),FILTER(ALLSELECTED('Sheet1'),'Sheet1'[Type]="Brand 1"&&'Sheet1'[Date]>=DATE(YEAR(MAX('Sheet1'[Date]))-1,MONTH(MAX('Sheet1'[Date])),DAY(MAX('Sheet1'[Date])))&&'Sheet1'[Date]<=MAX('Sheet1'[Date])))

2. Result:

vyangliumsft_0-1643177088325.png

Will vary with the filter: say, filter out October 2021, and the result will vary

vyangliumsft_1-1643177088329.png

 

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

Such a huge help.

Was able to fix my orginal formula that didn't work: 

Closer Rate YTD move back 3 months =
CALCULATE(
1-DIVIDE(
SUM('Monthly Data'[Still to be invoiced (val.)]),
SUM('Monthly Data'[Net Order Value])),
DATESINPERIOD(
'Calendar'[Date],
ENDOFMONTH(DATEADD('Calendar'[Date],-3,MONTH)),
-1,
YEAR)
)

 

To a formula that did work: 

Closer Rate YTD Roll Back 3 months =
CALCULATE(
1-DIVIDE(
SUM('Monthly Data'[Still to be invoiced (val.)]),
SUM('Monthly Data'[Net Order Value])),
FILTER(ALLSELECTED('Monthly Data'),
'Monthly Data'[Document Date]>=DATE(YEAR(MAX('Monthly Data'[Document Date])),
MONTH(MAX('Monthly Data'[Document Date]))-15,
DAY(MAX('Monthly Data'[Document Date])))&&
'Monthly Data'[Document Date]<=DATE(YEAR(MAX('Monthly Data'[Document Date])),
MONTH(MAX('Monthly Data'[Document Date]))-3,
DAY(MAX('Monthly Data'[Document Date])
)
)))

 

 

Thank you so much!!!!!

 

 

Samarth_18
Community Champion
Community Champion

Hi @Caldowd98 ,

 

Kindly share some sample data in text format with desired output, it will help us to answer more specifically. 🙂

NOTE:- Time intelligence functions work well when you have date table in your model. Try to add calender table into the model then hopefully you will get desired output.

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.