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
jhmonson
New Member

Drop 3 highest and 3 lowest values from static 12 month average

I'm sharing a pbix file (attached)...

 
https://drive.google.com/file/d/1zXK30zA517fa1yAjkvqs0iJbtScLskqt/view?usp=sharing

 

Hello! I have a data set containing number of uses of an item by month for 12 months. I need to be able to pick an item from the slicer and have the table show usage in each month column 1, the average of the 12 months in every row (not rolling) as column 2 (I've done this in a measure calculating the average for the selected item with an ALL function), and the average with the top 3 and bottom three values dropped in column 3. The last part is where I'm getting stuck. Here's my visual so far: 

 

jhmonson_4-1647028297435.png

So I'm looking for one more column that would drop the highest and lowest three values from usage and average the remaining 6 for whatever item I have selected, eventually looking something like this if I've picked item 100008:

 

jhmonson_5-1647028337415.png

 

Any ideas? Thanks!

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Mid AVG = 
VAR __m = ALLSELECTED( 'Usage Data'[Month] )
VAR __rank = [RANK]
RETURN
    IF(
        __rank > 3 && __rank <= COUNTROWS( __m ) - 3,
        AVERAGEX(
            FILTER(
                __m,
                VAR __r = [RANK]
                RETURN
                    __r > 3
                        && __r <= COUNTROWS( __m ) - 3
            ),
            [Total]
        )
    )

CNENFRNL_0-1647055966469.png

 

Excel worksheet formula is way powerful to solve such a simple question,

CNENFRNL_1-1647056022982.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Community Champion
Community Champion

Mid AVG = 
VAR __m = ALLSELECTED( 'Usage Data'[Month] )
VAR __rank = [RANK]
RETURN
    IF(
        __rank > 3 && __rank <= COUNTROWS( __m ) - 3,
        AVERAGEX(
            FILTER(
                __m,
                VAR __r = [RANK]
                RETURN
                    __r > 3
                        && __r <= COUNTROWS( __m ) - 3
            ),
            [Total]
        )
    )

CNENFRNL_0-1647055966469.png

 

Excel worksheet formula is way powerful to solve such a simple question,

CNENFRNL_1-1647056022982.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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.