Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Row wise grouping using DAX


Hi All,

Have data set like above image and am struggling for grouping of data, row wise. using DAX or MDAX.
Like in above image "short_lable" column having "Tremination point" and sequence nos. are in squence. 
So what is expecting in output column, till Termination Point above quesions in one Group like group1,group2 ,..... 
groups sequence should be depend on sequence no.

Please refer above image .

Thanks ,
PD
 

  • Hi Anonymous ,

    Sorry for late back. Modify the formula to:

    Column =
    " Group "
        & RANKX (
            FILTER ( 'Table', 'Table'[pre code] = EARLIER ( 'Table'[pre code] ) ),
            MINX (
                FILTER (
                    'Table',
                    'Table'[Sequence No] >= EARLIER ( 'Table'[Sequence No] )
                        && 'Table'[Short_Label] = "Termination point"
                        && 'Table'[pre code] = EARLIER ( 'Table'[pre code] )
                ),
                'Table'[Sequence No]
            ),
            ,
            ASC,
            DENSE
        )
    

    Get the correct result.

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ kalyj

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

     

4 Replies

  • Anonymous , Create the column

     

    new seq = maxx(filter(Table, Table[squence] >= earlier([sequence]) && [short_label] ="Tremination point" ), [sequence] )

     

    Group = " Group " & Rankx(filter(Table, [new seq] = earlier([new seq])) , [sequence],,asc,dense)

     

     

  • Hi Anonymous ,

    According to your description, here's my solution, create a calculated column.

    Column =
    " Group "
        & RANKX (
            'Table',
            MINX (
                FILTER (
                    'Table',
                    'Table'[Sequence No] >= EARLIER ( 'Table'[Sequence No] )
                        && 'Table'[Short_Label] = "Termination point"
                ),
                'Table'[Sequence No]
            ),
            ,
            ASC,
            DENSE
        )
    

    Get the correct result.

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ kalyj

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-yanjiang-msft ,
      Thanks for suggestion ...
      but now data has been updated have to consider "Pre Code" as well same scenario but if perception code change group should start like G1,G2,G3 again ..... because sequence no start with 100 with every new Pre code.


      Thanks ,
      PD

      • v-yanjiang-msft's avatar
        v-yanjiang-msft
        Community Support

        Hi Anonymous ,

        Sorry for late back. Modify the formula to:

        Column =
        " Group "
            & RANKX (
                FILTER ( 'Table', 'Table'[pre code] = EARLIER ( 'Table'[pre code] ) ),
                MINX (
                    FILTER (
                        'Table',
                        'Table'[Sequence No] >= EARLIER ( 'Table'[Sequence No] )
                            && 'Table'[Short_Label] = "Termination point"
                            && 'Table'[pre code] = EARLIER ( 'Table'[pre code] )
                    ),
                    'Table'[Sequence No]
                ),
                ,
                ASC,
                DENSE
            )
        

        Get the correct result.

        I attach my sample below for your reference.

         

        Best Regards,
        Community Support Team _ kalyj

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