cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IanLittlejohn
New Member

DatesInPeriod with Leap Year

I'm using a DatesInPeriod with an =Calculate formula.  The DatesInPeriod goes 6 months back,  This works perfectly, except for Feb 2016 which is a leap year.  It calculates 7 months.  Has anybody else had this problem with the leap year?  

5 REPLIES 5
Community Support
Community Support

Re: DatesInPeriod with Leap Year

Hi @IanLittlejohn

How do you write the formula? it is a calculated column or a measure?

Could you share me the formula nad the screenshot when apply the formula?

 

I test with the following formula, it calculate the value from 2015/9/1~2016/2/29, Does this meet your need?

Column = CALCULATE(SUM(Sheet2[value]),DATESINPERIOD(Sheet2[date],DATE(2016,2,29),-6,MONTH))

 

 

Best Regards

Maggie

Super User IV
Super User IV

Re: DatesInPeriod with Leap Year

Hi,

 

Try this measure

 

=CALCULATE(SUM(Data[Value]),EDATE(MIN(Calendar[Date]),-6))

 

There should be a relationship from the Date column of the Data Table to the Date column of the Calendar Table.  Ensure that in the filter or slicer, you select any one month.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
IanLittlejohn
New Member

Re: DatesInPeriod with Leap Year

Hi Maggie,

 

Thanks for the suggestion.  I'm using a rolling calculation for the last 6 months sales.  I'm passing the end date as a variable from another table.

 

T6 Months Sales =

var lastsaledate = lastdate('Data'[Date])
Return
CALCULATE([Sales Total],all('Date Master Table'),DATESINPERIOD('Date Master Table'[Master Date],lastsaledate,-6,MONTH))

 

So I'm not able to hard code the starting date as per your suggestion

IanLittlejohn
New Member

Re: DatesInPeriod with Leap Year

Hi Ashish, I tied using the edate but it returns one value for the last 6 months.  I'm looking for a rolling 6 months total to be calculated. Thanks for the suggestion

Community Support
Community Support

Re: DatesInPeriod with Leap Year

Hi @IanLittlejohn

I make a test on my site as below

for 2016/2, it calculates the last 6 months sales between 2015/9~2016/2

for 2016/7,  it calculates the last 6 months sales between 2016/2~2016/7

Is my test correct?

8.png

 

 

Could you provide some screenshot on your side for better analysis?

 

Additionally, here are some other methods about rolling 6 months sum

https://www.kasperonbi.com/show-only-the-sales-for-the-last-12-months/

https://community.powerbi.com/t5/Desktop/Calculate-Moving-Average-Last-6-Month-with-not-sequencial-D...

https://stackoverflow.com/questions/50357343/power-bi-rolling-6-month-sum

 

Best Regards

Maggie

 

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors