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
Anonymous
Not applicable

Dynamic Sum of Total Sales by Quarter Ranked from High to Low

I am trying to calculate a dynamic average for the highest 3 Total Sales Quarters averaged to use as a target, so in theory if a new quarter had the highest bookings then it would replace number 1 ranked and all others drop down by 1 position.

 

I have a table that looks like this:

DrewSTaylor_0-1658849161837.png

 

I have Total Bookings

 
Total Bookings =
CALCULATE(
sum('fact'[Amount]),
'fact'[type]="Closed")    
 
I have my Quarterly Bookings Ranked 
 
Quarterly Bookings Ranked =
RANKX(All('Calendar Table'[Year Quarter]),
'fact'[Total Bookings])
 
so now what I want to do is a new measure that gives an average of the top 3. I have written this DAX but I get an error
 
Average Bookings Top 3 Ranked =
CALCULATE(
'fact'[Total Bookings] / 3,
'fact'[Quarterly Bookings Ranked] = "1"||"2"||"3")
 
so essentially calculates the Total Bookings where Rank = 1 or 2 or 3 and divides by 3 to give an average.
 
I get this error
 
DrewSTaylor_1-1658849457076.png

Any help with this would be great

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , Try one of the two

 

CALCULATE(AverageX(values('Calendar Table'[Year Quarter]),[Total Bookings]) ,TOPN(3,allselected('Calendar Table'[Year Quarter]),[Total Bookings],DESC),VALUES('Calendar Table'[Year Quarter]))


CALCULATE(AverageX(values('Calendar Table'[Year Quarter]),[Total Bookings]) ,TOPN(3,allselected('Calendar Table'[Year Quarter]),[Total Bookings],DESC))

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.