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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pooja9
Frequent Visitor

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

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

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.

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

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

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

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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