Forum Discussion
Aerobat
5 years agoFrequent Visitor
Extracting a hierarchy from a range
I already posted a similar problem wher I got some fine help from this amazing community. Now I have developed things a bit further and need to extract the hierarchy from a range and the value a me...
Aerobat
5 years agoFrequent Visitor
Code in better format
let
Source1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fVNBcoIwFL1KxnWZIorVJQ7IUC2dQezGcRFNYKIWOwG8QT2DJ/AM3edizQ8gkZl29V4m7+W/n/ys170gI8WeZixL8y0jHKe9p17fNE0Jw8HEqleG4pundc9JDHRKUUZJfuDsDEbKEU4Qzo7ipruHk9HdDRzcEc3LY4ELlIgfjjjNCso1i23bdwtwZfGWq0XsxGgmrhFazp1YM4wVVAbgYBDfnBa5PLwqpaknw8ldDRzUKwJRCoT5lu4Jhf1+3+wACN/fluISh0Hoo8jzAZdONPVeXU8XDxqPofijURNa41YIHISuuMzVudPAjRxNbZkvd7XinTxxsJiu3Ic4o8pQVxlBnLpKzI7bkuR1vxwZCD/vdHELIA9SnKVncZNvRSjSXF+cfZ5UK3VHLSif74T+h7hEXuh6qI4W6UKr0RuK/1tMvmRTzTI7oKYydCMPBaEbi4sf13UGtnbTctXetJOkLJGjB5NcsGMzuNbQ7ICapyunOOFlRmDY1Y5tdgB0c5znlLAkoTL+TsVm8nPJs9UMWtWTaPCHqSQQTomqZ9cALDN8KEqOOd7Kf2SggwxWfaKm0xY2m18=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Number = _t, Endnumber = _t, Range = _t]),
Source = Table.TransformColumnTypes(Source1,{{"Name", type text}, {"Number", Int64.Type}, {"Endnumber", Int64.Type}, {"Range", type text}}),
A = Table.AddColumn(Source,"m",each
let
a=Table.ToRows(Table.SelectRows(Table.FirstN(Source,List.PositionOf(Source[Name],[Name])),(x)=>x[Range]<>null)),
b=List.Transform(a,(y)=>if [Number]<=y{2} and [Number]>=y{1} then List.RemoveRange(y,2,1) else {})
in
List.RemoveRange(Record.ToList(_),2,1)&List.Combine(b)
),
Result = Table.FromList(A[m],each _,List.Count(List.Last(A[m])))
in
Resultshaowu459
5 years agoResolver II
In order to better understand your case, could you post a picture of the expected result of below table?
- Aerobat5 years agoFrequent Visitor
I think it should be something like this:
Name Number Endnumber Range Parent Parent Number Parent Endnumber Parent Range Årets resultat 1000 4949 1000-4949 RESULTAT FØR SKAT 1000 4800 1000-4800 Årets resultat 1000 4949 1000-4949 Resultat før renter 1000 4555 1000-4555 RESULTAT FØR SKAT 1000 4800 1000-4800 Af- og nedskrivninger af anlæg 1000 4496 1000-4496 Resultat før renter 1000 4555 1000-4555 Indtjeningsbidrag 1000 4392 1000-4392 Af- og nedskrivninger af anlæg 1000 4496 1000-4496 DÆKNINGSBIDRAG 1110 2070 1110-2070 Indtjeningsbidrag 1000 4392 1000-4392 OMSÆTNING 1110 1280 1110-1280 DÆKNINGSBIDRAG 1110 2070 1110-2070 OMSÆTNING REGNINGSARBEJDE 1110 1130 1110-1130 OMSÆTNING 1110 1280 1110-1280 Udført arbejde 1110 1110 1110 OMSÆTNING REGNINGSARBEJDE 1110 1130 1110-1130 OMSÆTNING TILBUDSARBEJDE 1160 1180 1160-1180 OMSÆTNING 1110 1280 1110-1280 Tilbudsarbejder - a/c 1180 1180 1180 OMSÆTNING TILBUDSARBEJDE 1160 1180 1160-1180 IGANGVÆRENDE ARBEJDER 1210 1220 1210-1220 OMSÆTNING 1110 1280 1110-1280 Igangværende arbejder - primo 1210 1210 1210 IGANGVÆRENDE ARBEJDER 1210 1220 1210-1220 Igangværende arbejder - ultimo 1220 1220 1220 IGANGVÆRENDE ARBEJDER 1210 1220 1210-1220 ANDRE INDTÆGTER 1235 1280 1235-1280 OMSÆTNING 1110 1280 1110-1280 Afgifter og tillæg 1240 1240 1240 ANDRE INDTÆGTER 1235 1280 1235-1280 Øreafrundning 1250 1250 1250 ANDRE INDTÆGTER 1235 1280 1235-1280 Kassedifferencer - indtægt 1260 1260 1260 ANDRE INDTÆGTER 1235 1280 1235-1280 Kassedifferencer - udgift 1270 1270 1270 ANDRE INDTÆGTER 1235 1280 1235-1280 Fakturarabat - kunder 1280 1280 1280 ANDRE INDTÆGTER 1235 1280 1235-1280