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
stericontrol
Regular Visitor

AVERAGE 4 HIGHEST LAST 12 MONTHS

I need to find and select the 4 highest values of each row (amount of products per month) from the table and calculate the average, always considering the last 12 months (moving). My data is from 2016 to date, I use a date dimension table "dCalendar", "dProducts" and a sales fact table "fSales".

 

How could I do this by creating a measure using DAX?


P.S.: I had a (partial) solution but I have a long period of date the information returned seems inconsistent.

https://community.powerbi.com/t5/DAX-Commands-and-Tips/AVERAGE-3-HIGHEST/m-p/2060786#M46496
Best Response: VahidDM

 

best regards

2 REPLIES 2
amitchandak
Super User
Super User

@stericontrol , Try have measure like these, assuming you have measure amount

 

calculate(AverageX(Table,[amount]),TOPN(4,allselected(Date[Month Year]),[amount ],DESC), values(Date[Month Year]))

 

or

 

calculate(AverageX( values(Date[Month Year]),[amount]),TOPN(4,allselected(Date[Month Year]),[amount ],DESC))

Hello @amitchandak ,
Thanks for the answer! I need to see the top 4 average by product. How can I create this measure considering this too?
Forgive the question if it seems amateur, I'm a beginner.

best regards

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.

Top Solution Authors