Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Add + 1 to previous row

Hi All

 

I was able to create the "Cycle" column using this formular in MS Excel: =IF(A2=A1;IF(B2 = "Reboot";C1+1;C1+0);0). Basically, if the name in the current row matches the name in the previous row, the proceed but if not then 0. The formular proceeds to add 1 to subsequent tasks when TaskName  = Reboot. It's quite easy in Excel, but can it be done in Power BI? 

 

NameTaskNameCycle
MtsweniEnrol0
MtsweniInvite0
MtsweniReboot1
MtsweniConsult1
MtsweniReboot2
MtsweniRecord BC2
MtsweniRecord BC2
MtsweniFarewell2
MtsweniConsult2
MtsweniReboot3
MtsweniConsult3
MtsweniConsult3
ThabisoEnrol0
ThabisoInvite0
ThabisoSent Reminder0
ThabisoReboot1
ThabisoSend Materials1
ThabisoReboot2
ThabisoRecord BC2
ThabisoRecord BC2
ThabisoFarewell2
ThabisoConsult2
ThabisoReboot3
ThabisoConsult3
ThabisoConsult3
ThabisoComprehensive Diabetes Tests3
ThabisoSend Materials3
PaulEnrol0
PaulInvite0
PaulSend Materials0
PaulWelcome0
PaulReboot1
PaulRecord BC1
PaulReboot2
PaulRecord BC2
PaulRecord BC2
PaulFarewell2
PaulConsult2
PaulReboot3
PaulConsult3
PaulConsult3
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi @thabz_mogale,

     

    Please check following calculated column as below and see if it meet your exception:

     

    Cycle =

    CALCULATE (

        COUNTROWS ( 'Table' ),

        FILTER (

            'Table',

            'Table'[Name] = EARLIER ( 'Table'[Name] )

                && 'Table'[Index] <= EARLIER ( 'Table'[Index] )

                && 'Table'[TaskName] = "Reboot"

        )

    ) + 0

     

    Result would be shown as below:

     

    Best Regards,

    Jay

     

    Community Support Team _ Jay Wang

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

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi @thabz_mogale,

     

    Please check following calculated column as below and see if it meet your exception:

     

    Cycle =

    CALCULATE (

        COUNTROWS ( 'Table' ),

        FILTER (

            'Table',

            'Table'[Name] = EARLIER ( 'Table'[Name] )

                && 'Table'[Index] <= EARLIER ( 'Table'[Index] )

                && 'Table'[TaskName] = "Reboot"

        )

    ) + 0

     

    Result would be shown as below:

     

    Best Regards,

    Jay

     

    Community Support Team _ Jay Wang

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