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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
davehus
Memorable Member
Memorable Member

Add 3 Year average to my report

Hi, I need to be able to get a 3 year average a product and also be able to display it by month. I've created a pattern but can't figure how to exclude the filter context for current year in the report.

Actual Qty Average = 
Var FirstSDate = CALCULATE(STARTOFYEAR('Date Table'[DateKey]), KEEPFILTERS('Date Table'[Delta Years]=0))
RETURN
CALCULATE(AVERAGEX(VALUES('Date Table'[Year]),[Actual Qty]),KEEPFILTERS('Date Table'[DateKey]<FirstSDate))

davehus_0-1618397472962.png

I need these results to appear in this report below when the specific product code and 2021 is selected from date table..

davehus_1-1618397574949.png

 

 

1 ACCEPTED SOLUTION

Thanks for your help @amitchandak , I figured it out in the end, I got the desired result with the pattern below.😁

 

3 Year Average = 
Var FirstSDate = CALCULATE(STARTOFYEAR('Date Table'[DateKey]), KEEPFILTERS('Date Table'[Delta Years]=0))
RETURN
CALCULATE(AVERAGEX(VALUES('Date Table'[Year]),[Actual Qty]),KEEPFILTERS('Date Table'[DateKey]<FirstSDate),REMOVEFILTERS('Date Table'[Year]))

 

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@davehus , Try a measure like with date table

Rolling 3 day = CALCULATE(Average('Table'[Number]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-3,Day))

or

Rolling 3 = divide( CALCULATE(sum(Sales[Sales]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date]),-3,Day)) ,
CALCULATE(distinctCOUNT('Date'[Month Year]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-3,Day), filter(Sales,not(isblank(sum(Sales[Sales]))))))

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

 

Hi @amitchandak , Thanks for the reply 🙂 

 

I've got that bit figured, I just need it to appear in my report when I filter on the current year. The measure looks at the prior 3 years so I need the measure to ignore the filters on my report. Hope that makes sense.

 

D

@davehus , if you do not need a trend then above with

Rolling 3 day = CALCULATE(Average('Table'[Number]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-3,Year), all(Date))

 

or //only at year level

CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]>=max('Date'[Year])-3 && 'Date'[Year]<=max('Date'[Year])) )

 

 

If you need trend, means show three year when one is selected, you need an independent table, refer my video

https://www.youtube.com/watch?v=44fGGmg9fHI&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L&index=18

Thanks for your help @amitchandak , I figured it out in the end, I got the desired result with the pattern below.😁

 

3 Year Average = 
Var FirstSDate = CALCULATE(STARTOFYEAR('Date Table'[DateKey]), KEEPFILTERS('Date Table'[Delta Years]=0))
RETURN
CALCULATE(AVERAGEX(VALUES('Date Table'[Year]),[Actual Qty]),KEEPFILTERS('Date Table'[DateKey]<FirstSDate),REMOVEFILTERS('Date Table'[Year]))

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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