cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mim Member
Member

find min and max by group and continuous order

using DAX how to calculate min and max for this table, based on the attribute color and they have to be in the same sequence , for example red -3 and red -6 are not considered in the same group as 3 and 6 are not in a continuous orderorder by.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: find min and max by group and continuous order

Hi @mim 

 

Please see the attached file with the solution.

The file contains
Calculated column

rankColorGroup = 
VAR __previousColor = 'Table'[color]
RETURN
    RANKX (
        FILTER ( 'Table', 'Table'[color] <> __previousColor ),
        'Table'[order],,,
        DENSE
    )

Two Measures

min = 
CALCULATE(
    MIN( 'Table'[order] ),
    ALL( 'Table' ),
    VALUES( 'Table'[rankColorGroup] )
)
max = 
CALCULATE(
    MAX( 'Table'[order] ),
    ALL( 'Table' ),
    VALUES( 'Table'[rankColorGroup] )
)
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

View solution in original post

1 REPLY 1
Super User
Super User

Re: find min and max by group and continuous order

Hi @mim 

 

Please see the attached file with the solution.

The file contains
Calculated column

rankColorGroup = 
VAR __previousColor = 'Table'[color]
RETURN
    RANKX (
        FILTER ( 'Table', 'Table'[color] <> __previousColor ),
        'Table'[order],,,
        DENSE
    )

Two Measures

min = 
CALCULATE(
    MIN( 'Table'[order] ),
    ALL( 'Table' ),
    VALUES( 'Table'[rankColorGroup] )
)
max = 
CALCULATE(
    MAX( 'Table'[order] ),
    ALL( 'Table' ),
    VALUES( 'Table'[rankColorGroup] )
)
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

View solution in original post

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)