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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Soumik
Regular Visitor

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 @Soumik ,

 

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 @Soumik ,

 

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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