The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I am trying to make a for loop in power query but I am unable to.
I need to create a new column that accumulates +1 if for the same employee and successive dates and situation="abs" increments its value by 1 otherwise it would have to restart at 0.
I have tried List.Generate, but I don't know how to implement it in a column.
it's hard to do this with Table.AddColumn, suggest you to add a new step with this code
NewStep=Table.FromRecords(List.Accumulate(Table.ToRecords(PreviousStepName),{{},"",0,0},(x,y)=>if y[Empoyee]=x{1} and y[Situation]="ABS" and y[Date]=Date.AddDates(x{2},1) then {x{0}&{y&[LD=x{3}+1]},y[Employee],y[Date],x{3}+1} else {x{0}&{y&[LD=Byte.From(y[Situation]="ABS")]},y[Employee],y[Date],Byte.From(y[Situation]="ABS")}){0})