Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Increment variable after condition

Hi Guys,

 

I need a help with the case below:

How to write it in Dax or Powerquery a code like this below:

 

Expected Result =

VAR V_ID = 1
RETURN

    if('Table'[OverflowAlarm] = 1 && 'Table'[Previus row] = 0, V_ID, 
        if('Table'[OverflowAlarm] = 0 && 'Table'[Previus row] = 1,    V_ID = V_ID +1 ,

           if ('Table'[OverflowAlarm] = 1 && 'Table'[Previus row] = 1, 'Table'[OverflowAlarm],0
)))

 

I have a table like that:

Time/datePoint_IdIndexDurationOverflowAlarmPrevius row
14/03/2018 23:45PDD1114878241151 
14/03/2018 23:30PDD11148782421511
14/03/2018 23:15PDD11148782431511
14/03/2018 23:00PDD11148782441511
14/03/2018 22:45PDD11148782451511
14/03/2018 22:30PDD11148782461510
14/03/2018 22:15PDD1114878247000
14/03/2018 22:00PDD1114878248000
14/03/2018 21:45PDD1114878249000
14/03/2018 21:30PDD1114878250000
14/03/2018 21:15PDD1114878251000
14/03/2018 21:00PDD1114878252000
14/03/2018 20:45PDD1114878253001
14/03/2018 20:30PDD11148782541510
14/03/2018 20:15PDD1114878255001
14/03/2018 20:00PDD11148782561511
14/03/2018 19:45PDD11148782571511
14/03/2018 19:30PDD11148782581511
14/03/2018 19:15PDD11148782591511
14/03/2018 19:00PDD11148782601511

 

And that is the result that I need:

 

Point_IdIndexDurationOverflowAlarmPrevius rowExpected Result
PDD1114878241151 event 1
PDD11148782421511event 1
PDD11148782431511event 1
PDD11148782441511event 1
PDD11148782451511event 1
PDD11148782461510event 1
PDD1114878247000 
PDD1114878248000 
PDD1114878249000 
PDD1114878250000 
PDD1114878251000 
PDD1114878252000 
PDD1114878253001 
PDD11148782541510event 2
PDD1114878255001 
PDD11148782561511event 3
PDD11148782571511event 3
PDD11148782581511event 3
PDD11148782591511event 3
PDD11148782601511

event 3

 

Any help is welcome!

Thanks

3 Replies