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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Row wise grouping using DAX


TSG Image.png

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
 

1 ACCEPTED SOLUTION

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.

vkalyjmsft_0-1663914767687.png

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.

 

View solution in original post

4 REPLIES 4
v-yanjiang-msft
Community Support
Community Support

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.

vkalyjmsft_0-1663147137340.png

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
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.

Pooja9_0-1663592871215.png


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.

vkalyjmsft_0-1663914767687.png

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.

 

amitchandak
Super User
Super User

@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)

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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 community update carousel

Fabric Community Update - June 2025

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