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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Problem Filtering Dates

Hello,
 
I am trying to do a calculation over a 1 year period then limit that calculation or extend that calculation to a certain time period
 
CALCULATE(
[Daily Average Sales],ALL('Calendar'[Date].[Date]), DATESBETWEEN('Calendar'[Date].[Date],DATE(2017,8,1),DATE(2018,3,31)),
DATESBETWEEN(
'Calendar'[Date],
LASTDATE('Calendar'[Date])-365,
LASTDATE('Calendar'[Date])))
 
The above calculation is correctly beginning the function at the right date but it is continuing to do the calculation after the end date and I don't know why. I tried doing the same as above with only a 90 day period and the function worked. Any help would be greatly appreciated. Thanks.
6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

 

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Here is a set of dummy data with a demo of what I am trying to do. The last column is what I am trying to create in BI, but I want to do this calculation using different filter contexts changing the # of "widgets sold" for non 1 year periods back through time:

 

 

WidgetsDatesRolling Average Previous 12 MonthsRolling Average Month 13-24Growth Between Two Rolling Averages
146Jan-16N/aN/aN/a
322Feb-16N/aN/aN/a
131Mar-16N/aN/aN/a
335Apr-16N/aN/aN/a
258May-16N/aN/aN/a
180Jun-16N/aN/aN/a
110Jul-16N/aN/aN/a
345Aug-16N/aN/aN/a
385Sep-16N/aN/aN/a
135Oct-16N/aN/aN/a
250Nov-16236.0909091N/aN/a
418Dec-16251.25N/aN/a
267Jan-17261.3333333N/aN/a
19Feb-17236.0833333N/aN/a
300Mar-17250.1666667N/aN/a
252Apr-17243.25N/aN/a
264May-17243.75N/aN/a
123Jun-17239N/aN/a
94Jul-17237.6666667N/aN/a
1Aug-17209N/aN/a
294Sep-17201.4166667N/aN/a
476Oct-17229.8333333N/aN/a
373Nov-17240.0833333236.09090912%
146Dec-17217.4166667251.25-13%
385Jan-18227.25261.3333333-13%
21Feb-18227.4166667236.0833333-4%
11Mar-18203.3333333250.1666667-19%
219Apr-18200.5833333243.25-18%
88May-18185.9166667243.75-24%
7Jun-18176.25239-26%
297Jul-18193.1666667237.6666667-19%
363Aug-18223.33333332097%
18Sep-18200.3333333201.4166667-1%
396Oct-18193.6666667229.8333333-16%
242Nov-18182.75240.0833333-24%
350Dec-18199.75217.4166667-8%
341Jan-19196.0833333227.25-14%
65Feb-19199.75227.4166667-12%
491Mar-19239.75203.333333318%
442Apr-19258.3333333200.583333329%
8May-19251.6666667185.916666735%
156Jun-19264.0833333176.2550%
306Jul-19264.8333333193.166666737%
243Aug-19254.8333333223.333333314%

Hi,

 

The third colum there seems like a measure.  Can you share the raw data.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yuta-msft
Community Support
Community Support

Hi datakid1230,

 

Remove the all statement and try again:

Result =
CALCULATE (
    [Daily Average Sales],
    DATESBETWEEN (
        'Calendar'[Date].[Date],
        DATE ( 2017, 8, 1 ),
        DATE ( 2018, 3, 31 )
    ),
    DATESBETWEEN (
        'Calendar'[Date],
        LASTDATE ( 'Calendar'[Date] ) - 365,
        LASTDATE ( 'Calendar'[Date] )
    )
)

Regards,

Jimmy Tao

AlB
Community Champion
Community Champion

Hi @Anonymous

Can you share the pbix? It would be much easier to see what is going on 

Anonymous
Not applicable

No I can't share the information sorry. No worries if there is not enough information to provide an answer.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.

Top Solution Authors
Top Kudoed Authors