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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
chris_k
Helper I
Helper I

12 Month Moving Average of Measure with filter

Hello,

 

I am calculating a 12 month Rolling Average for some data. The data has both an "entity" and an "approved" (date) column.

 

What I need to do is filter this measure by the "entity" which works perfectly currently but when a date filter is applied to the report I need it to ignore the date filtering (i cant use the interactions as my filters are date and entity linked). I was thinking something along the lines of using the ALL function? Any advice?

 

Measure so far:

 

12m Rolling Average = 
VAR __LAST_DATE =
   ENDOFMONTH('data_source_one'[approved].[Date])

VAR __DATE_PERIOD =
   DATESBETWEEN(
      'data_source_one'[approved].[Date],
      STARTOFMONTH(DATEADD(__LAST_DATE, -12, MONTH)),
      __LAST_DATE
   )

RETURN
   AVERAGEX(
      CALCULATETABLE(
         SUMMARIZE(
            VALUES('data_source_one'),
            'data_source_one'[approved].[Year],
            'data_source_one'[approved].[QuarterNo],
            'data_source_one'[approved].[Quarter],
            'data_source_one'[approved].[MonthNo],
            'data_source_one'[approved].[Month]
         ),
         __DATE_PERIOD
      ),
      CALCULATE([Data To Date], ALL('data_source_one'[approved].[Day]))
   )
3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @chris_k,

 

Maybe you can sue the ALLEXCEPT to work on it.

 

ALLEXCEPT(your table, youtable[date])

Also kindly share your sample data and excepted result to me.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Sample data:

 

entityapprovedData To Date
511252018-09-01 00:00:000.00
2535642016-01-01 00:00:00NaN
2535642016-02-01 00:00:000.00
2535642016-03-01 00:00:000.00
2535642016-04-01 00:00:000.00
2535642016-05-01 00:00:0022.73
2535642016-06-01 00:00:000.00
2535642016-07-01 00:00:000.00
2535642016-08-01 00:00:000.00
2535642016-09-01 00:00:000.00
2535642016-10-01 00:00:000.00
2535642016-11-01 00:00:000.00
2535642016-12-01 00:00:000.00
2535642017-01-01 00:00:000.00
2535642017-02-01 00:00:000.00
2535642017-03-01 00:00:005.61
2535642017-04-01 00:00:000.00
2535642017-05-01 00:00:000.00
2535642017-06-01 00:00:000.00
2535642017-07-01 00:00:000.00
2535642017-08-01 00:00:000.00
2535642017-09-01 00:00:000.00
2535642017-10-01 00:00:000.00
2535642017-11-01 00:00:000.00
2535642017-12-01 00:00:000.00
2535642018-01-01 00:00:000.00
2535642018-02-01 00:00:002.19
2535642018-03-01 00:00:001.85
2535642018-04-01 00:00:000.00
2535642018-05-01 00:00:000.00
2535642018-06-01 00:00:000.00
2535642018-07-01 00:00:000.00
2535642018-08-01 00:00:000.00
2535642018-09-01 00:00:000.00

 

Expected result:

 

Ability to filter by "entity" to give the 12m rolling average but ignore all filters applied to "approved" column. (Without editing the interactions).

 

So for 253564 result = 0.27

When looking at all data result = 0.18

 

Thanks,

Chihiro
Solution Sage
Solution Sage

Try using ALLEXCEPT(). Or ALL(),VALUES() combo.

 

Note that you should add columns not to be ignored in the function.

 

You can find more detailed explanation in link.

https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.