Forum Discussion

seenai's avatar
seenai
Helper II
4 years ago
Solved

Add Custom Column 'Batch'

Hi,   I need to add 'custom column' like Index, in the below scenario :   The Index number changes only when change in ModelNo. Request your inputs.  
  • v-kkf-msft's avatar
    4 years ago

    Hi seenai ,

     

    1. Add the Index column.

     

     

    2. Add the following custom columns in Power Query Editor.

     

    = if [Index]=1 then null else #"Added Index"{[Index]-2}[ModelNo]

    = if [ModelNo]=[PrevRow] and [Index]-#"Added Custom"{[Index]-2}[Index]=1 then 1 else 0

     

    3. Create calculated columns:

     

    Index2 = 
    VAR MaxIndex =
        MAXX (
            FILTER (
                'Table',
                'Table'[Index] < EARLIER ( 'Table'[Index] )
                    && 'Table'[Custom] = 0
            ),
            'Table'[Index]
        )
    RETURN
        IF ( 'Table'[Custom] = 0, 'Table'[Index], MaxIndex )
    Order = RANKX ( 'Table', 'Table'[Index2], , ASC, Dense )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

    Best Regards,
    Winniz

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.