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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.