Forum Discussion
Pivot or...?
- 3 years ago
okay, i think i've fixed that bug. Try this:
let Source = your_table, f = (tbl as table) as table => [rows = Table.ToRecords(tbl), acc = List.Accumulate( rows, {}, (s, c) => if c[CLOCK_TYPE] = 51 then s & {c & [CHECKIN = c[DATETIMECHECK]] & [CHECKOUT = null]} else if List.IsEmpty(s) then s & {c & [CHECKIN = null] & [CHECKOUT = c[DATETIMECHECK]]} else if List.Last(s)[CHECKOUT] = null then List.RemoveLastN(s, 1) & {Record.TransformFields(List.Last(s), {"CHECKOUT", each c[DATETIMECHECK]})} else s & { c & [CHECKIN = null] & [CHECKOUT = c[DATETIMECHECK]]} ), out = Table.FromRecords(acc)][out], g = Table.Group(Source, {"SHIFT_NUMBER", "EMPLOYEE_CODE"}, {"all", each f(Table.Sort(_, "ABS_NUMBER"))}), expand = Table.ExpandTableColumn(g, "all", {"CLOCK_DATE", "CHECKIN", "CHECKOUT"}) in expand
Hi,
you need to do pivot on Clock type and set "No aggregation''. then rename 51 to Checkin and 52 to checkout.
here is a similar thread.
Solved: Re: pivot or transpose? - Microsoft Fabric Community
- pedroccamaraDBI3 years agoPost Partisan
Thank for your answer (again) rubayatyasmin
This is a different issue.
Could you please try it and let me know if you have the same result?
It's just a couple of records
Your idea give me this...(before renaming the column 51 and 52) and this is not what I want. Please check the image aboveor this if I remove abs_number before pivot
- rubayatyasmin3 years agoCommunity Champion
- pedroccamaraDBI3 years agoPost Partisan
Thank you for your answer rubayatyasmin
I don't think I need one because I already have the column ABS_NUMBER. But it won't work. I did it the way you've suggested. Remmeber what I want is in my original message. My first message. Your solution is not what I would like to have. I'm not saying that it should be done with pivot...