Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

SUM OF FIRST ROWS OF EVERY GROUP

Hi Team,

 

Newbie here,

 

May I ask if it is possible to create a DAX expression the will RESULT on like below image.

 

The raw data are TYPE ATTRIBUTE and SECONDS

 

RESULT should be the sum of first rows in SECONDS column per TYPE and ATTRIBUTE. 

 

 

Thank for assisting! Really appreciate the big help! 🙂 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    First create a Index column, then create three measures

    Rank1 = 
    CALCULATE(MIN('Table'[Index]),ALLEXCEPT('Table','Table'[Attribute],'Table'[Type]))
    Rank2 = 
    CALCULATE ( MIN ( 'Table'[Index] ), ALLEXCEPT ( 'Table', 'Table'[Attribute] ) )
    Result = 
    IF (
        MAX ( 'Table'[Index] ) = [Rank2],
        CALCULATE (
            SUM ( 'Table'[Seconds] ),
            FILTER ( ALLEXCEPT ( 'Table', 'Table'[Attribute] ), [Index] = [Rank1] )
        ),
        0
    )

     

    You can check more details from here.

     

     

    Best Regards,

    Stephen Tao

     

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    First create a Index column, then create three measures

    Rank1 = 
    CALCULATE(MIN('Table'[Index]),ALLEXCEPT('Table','Table'[Attribute],'Table'[Type]))
    Rank2 = 
    CALCULATE ( MIN ( 'Table'[Index] ), ALLEXCEPT ( 'Table', 'Table'[Attribute] ) )
    Result = 
    IF (
        MAX ( 'Table'[Index] ) = [Rank2],
        CALCULATE (
            SUM ( 'Table'[Seconds] ),
            FILTER ( ALLEXCEPT ( 'Table', 'Table'[Attribute] ), [Index] = [Rank1] )
        ),
        0
    )

     

    You can check more details from here.

     

     

    Best Regards,

    Stephen Tao

     

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