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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Kmur
Regular Visitor

Rolling average with custom calendar slicer

Hi all,

 

My report end users have asked me to create slicer for periods, where all graphs act to periods according to selected one (months, quarters, half year, year). They didn´t like the drill-down on each graph

I created table in Query based on my calendar table where I have all previously mentioned periods and calendar key as unique ID. Then unpivoted, connected to original calendar table and used this as a slicer. For my measures I´m using crossfilter and they all work nicely exept 12m rolling average. 

 

Here are my formulas:

Rolling 12 mth average =
IF (
ISBLANK(CALCULATE([Amount_TOTAL LY];DATEADD(Original_Calendar[CALENDAR_DATE]; 1;MONTH)));
BLANK();
(
CALCULATE (
[Amount_TOTAL LY];
DATESINPERIOD(
Original_Calendar[CALENDAR_DATE];
MAX(DATA_TABLE[TIME_PERIOD_DATE]);
13;MONTH
)
) - [Amount_TOTAL LY]
) / 12
)

 

Result of rolling average seems to calculate only the last part of the formula as my figures end up "-" but all should be positive. 

I have also tried to replace Original_Calendar with a date from "Period selectors" table but no result in months at all only in Q, HY & Y but also not correct. 

 

Measures used: (they work correct)

Amount_TOTAL LY =
CALCULATE([Amount_TOTAL];SAMEPERIODLASTYEAR(DISTINCT('Period selectors'[CALENDAR_DATE]));ALL('Period selectors'))

 

 Amount_TOTAL = CALCULATE(sum(DATA_TABLE[Amount]);CROSSFILTER(D_CALENDAR[CALENDAR_KEY];'Period selectors'[CALENDAR_KEY]; both))

 

"Period selectors" is the table I created to have a period slicer. 

 

Hope someone could help on this.

 

Thanks, Kertu

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@Kmur,

 

You may try applying virtual relationship in DAX.

http://community.powerbi.com/t5/Desktop/Relational-Date-Filter-By-Other-Date-How-To/td-p/298373

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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