Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Custom column index

Hi Guys,   First time poster but I have been working with Powerbi for couple of months so not completely new to it. I have been working on this problem for couple of days and have looked through mu...
  • AlB's avatar
    5 years ago

    Anonymous 

    Try this, with a minor change on how the ties are broken. It uses the Index column, which we didn't have at the beginning but is very useful. Seems to match the expected results on your uploaded  sample:

     

    Attempt V2 =
    VAR breakTies_ =
        RANKX (
            CALCULATETABLE (
                Table1,
                ALLEXCEPT ( Table1, Table1[Site], Table1[Operation] ),
                Table1[Time Stamp] = EARLIER ( Table1[Time Stamp] ),
                RIGHT ( Table1[Step], 3 ) = "001"
            ),
            Table1[Index]
        ) - 1
    RETURN
        CALCULATE (
            COUNT ( Table1[Step] ),
            ALLEXCEPT ( Table1, Table1[Site], Table1[Operation] ),
            RIGHT ( Table1[Step], 3 ) = "001",
            Table1[Time Stamp] <= EARLIER ( Table1[Time Stamp] )
        ) - breakTies_

     

     

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers