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

Highlighted
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
Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ Integration Forum Launch

‘Better Together’ Integration Forum Launch

We've launched a how-to forum where you can learn about how Power BI integrates with other Power Platform products.

Top Solution Authors
Top Kudoed Authors