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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors