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
Greg888
Helper I
Helper I

Getting a max step from a group

Hi All

 

I have what I think could be a fairly simply problem to solve but I have been going around and around in circles to try to get the answer and now I'm just stuck or not understanding why this would not work.

I have a table below and I want to identify with a 1 which step is the max step in the GROUP, the unique or grouped item is the DocNumber and the group has several steps, all I am trying to do is to add an indicator to say the highest step number I have tried some what I thought would work calculation but it always ends up the same way 😞

GroupMaxStep.PNG




1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

MaxStepNo =
MAXX(
    FILTER(
        'Document Steps',
        'Document Steps'[DocNumber] = EARLIER( 'Document Steps'[DocNumber] )
    ),
    'Document Steps'[StepNo]
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

MaxStepNo =
MAXX(
    FILTER(
        'Document Steps',
        'Document Steps'[DocNumber] = EARLIER( 'Document Steps'[DocNumber] )
    ),
    'Document Steps'[StepNo]
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

ok thank you for this so that produced the last step correctly as a number in the column

I then did a 

IF(Document Steps [MaxStep] = DocumentSteps[StepNo],1,0)

Which has given me a column I can use going foward. Thanks for all your help

SpartaBI
Community Champion
Community Champion

@Greg888 

 

 

MaxStepNo = 
VAR _current_doc = 'Document Steps'[DocNumber]
RETURN
CALCULATE(
    MAX('Document Steps'[StepNo]),
    REMOVEFILTERS('Document Steps'),
    'Document Steps'[DocNumber] = _current_doc
)

 

 

 

In case it answered your question, please accept it as a solution to help the other members find it more quickly. Appreciate Your Kudos 💪
Showcase Report – Contoso By SpartaBI 
Website Linkedin Facebook 
This is SpartaBI!

Sadly gives me the exact same result of  my original query

SpartaBI
Community Champion
Community Champion

@Greg888 Very strange! Did you change something in what I sent you? I see in your measure you want to return 1 or 0. Did you wrap my measure with additional logic for that?

@Greg888 the two measures give the same result...
How did the 1st one didn't work and 2nd did..?
(In my sample data the Doc number is group id and the step is Value for ID. I just used it on somethong that was open on my pc from another question)

SpartaBI_1-1652102766997.png

 

SpartaBI_0-1652102576805.png

 

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.