cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
may17
New Member

Matrix - last 3 months' average to be appended to matrix

Hi,

 

I have created a matrix like the one below using a calculated field that shows displays Sales numbers across 2 levels, as a % (percentage) of the previous level, Level 1 and 2 being STATE and CITY.

 

I would like to add another column towards the end that displays the average of this % metric, for the last 3 months of my dataset. Currently, I am working with data till January 2018. However, as I keep adding new data every month, this will change.

 

Request your help with a DAX formula to implement this.

 Power BI Query.PNG

 

Below are the formulae I have used for the calculated field-

 
% level 2 = DIVIDE(sum('Sales Data'[Sales]),CALCULATE(sum('Sales Data'[Sales]),ALLSELECTED('Sales Data'[CITY])  ) )
 
% level 1 = DIVIDE(sum('Sales Data'[Sales]),CALCULATE(sum('Sales Data'[Sales]),ALLSELECTED('Sales Data'[STATE])  ) )
 
Level 1 = if([% level 2]=1 , [% level 1],[% level 2])        #This is the field I used for the matrix
 
 
3 month rolling average formula that did not work-
3mnth = CALCULATE([Level 1],DATESINPERIOD('Sales Data'[Reporting Month],LASTDATE('Sales Data'[Reporting Month]),-3,MONTH))/3
 
 
1 REPLY 1
v-jiascu-msft
Microsoft
Microsoft

Hi @may17,

 

Just see from the formula, it should work. I would suggest you create an independent date table and establish relationships with other tables. Can you share a sample?

 

Best Regards,

Dale

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

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors