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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

DAX Formula for the excel function below

Could you please help me with the equivalent DAX formula/code for the below mentioned Excel function

 

=AVERAGE(LARGE(Sheet1!A2:A21, INT((COUNT(Sheet1!A2:A21)-1)/4)+1),LARGE(Sheet1!A2:A21, INT(COUNT(Sheet1!A2:A21)/4)+1))

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1675131888295.png

Please try:

FIrst creeate an index column:

vjianbolimsft_1-1675131944273.png

Then apply the measure:

Measure =
VAR _a =
    FILTER ( 'Table', [Index] >= 1 && [Index] <= 20 )
VAR _b =
    INT ( ( CALCULATE ( COUNT ( 'Table'[Number] ), _a ) - 1 ) / 4 ) + 1
VAR _c =
    CALCULATE (
        MAX ( 'Table'[Number] ),
        FILTER ( _a, RANKX ( 'Table', [Number] ) = _b )
    )
VAR _d =
    INT ( CALCULATE ( COUNT ( 'Table'[Number] ), _a ) / 4 ) + 1
VAR _e =
    CALCULATE (
        MAX ( 'Table'[Number] ),
        FILTER ( _a, RANKX ( 'Table', [Number] ) = _d )
    )
RETURN
    AVERAGEX ( { _c, _e }, [Value] )

Final output:

vjianbolimsft_2-1675132779167.png

Best Regards,

Jianbo Li

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

View solution in original post

1 REPLY 1
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1675131888295.png

Please try:

FIrst creeate an index column:

vjianbolimsft_1-1675131944273.png

Then apply the measure:

Measure =
VAR _a =
    FILTER ( 'Table', [Index] >= 1 && [Index] <= 20 )
VAR _b =
    INT ( ( CALCULATE ( COUNT ( 'Table'[Number] ), _a ) - 1 ) / 4 ) + 1
VAR _c =
    CALCULATE (
        MAX ( 'Table'[Number] ),
        FILTER ( _a, RANKX ( 'Table', [Number] ) = _b )
    )
VAR _d =
    INT ( CALCULATE ( COUNT ( 'Table'[Number] ), _a ) / 4 ) + 1
VAR _e =
    CALCULATE (
        MAX ( 'Table'[Number] ),
        FILTER ( _a, RANKX ( 'Table', [Number] ) = _d )
    )
RETURN
    AVERAGEX ( { _c, _e }, [Value] )

Final output:

vjianbolimsft_2-1675132779167.png

Best Regards,

Jianbo Li

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.