New Columns with different/specific Requirements- Power BI

shansakhi

Active Member
Joined
Apr 5, 2008
Messages
300
Office Version
  1. 365
Platform
  1. Windows
Hello Friends,
I am trying to create two columns as highlighted in "green" below.
Columns highligted in "yellow" are the available data in table.

Column "Routing" - This is derived based on columns "Tkt No", "Seg" and "Route"
Column "Value (Actual)" - This is derived based on column "Value $" - In data entire ticket value is repeated for eash segment so that only on seg value to be considered.

P.S. - the sequecce of "Seg" may not be in order. we may have mixed data.

Book1
HIJKLM
2Ttk NoSegRouteValue ($)RoutingValue (Actual)
312341BOM-DEL105BOM-DEL-SXR-SXR-DEL-BOM105
412342DEL-SXR105BOM-DEL-SXR-SXR-DEL-BOM0
512343SXR-DEL105BOM-DEL-SXR-SXR-DEL-BOM0
612344DEL-BOM105BOM-DEL-SXR-SXR-DEL-BOM0
7
845671BOM-DEL55BOM-DEL55
9
1033151BOM-DEL75BOM-DEL-BOM75
1133152DEL-BOM75BOM-DEL-BOM0
12
1336721BOM-DEL95BOM-DEL-SXR-IXJ-DEL-BOM95
1436722DEL-SXR95BOM-DEL-SXR-IXJ-DEL-BOM0
1536723IXJ-DEL95BOM-DEL-SXR-IXJ-DEL-BOM0
1636724DEL-BOM95BOM-DEL-SXR-IXJ-DEL-BOM0
17
1832321BOM-DEL85BOM-DEL-CCU85
1932322DEL-CCU85BOM-DEL-CCU0
Sheet2


Regards,
SC
 
Hi @shansakhi,

if I have well understood.

Power Query:
let
A = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
B = Table.ColumnNames(A),
C = (x,y,z)=> Table.InsertRows(x, y, Table.ToRecords(#table(z, {List.Repeat({null}, List.Count(z))}))),
D = Table.Group(C(A,0,B), B{0}, {"x", each
 [
    a = Table.Sort(Table.Skip(_), B{1}),
    b = (x,y)=> List.Repeat({x},Table.RowCount(a) + y),
    c = Text.Combine(List.RemoveNulls(List.Combine(List.Accumulate( List.Transform(Table.Column(a,B{2}), each Text.Split(_,"-")),
        {{null,null}}, (s,c)=> s & {if List.Last(s){1} = c{0} then {null,c{1}} else c}))),"-"),
    d = Table.ToColumns(a) & {b(c, 0)} & {{Table.Column(a,B{3}){0}} & b(0,-1)},
    e = Table.FromColumns(d, B & {"Routing", "Value(Actual)"}),
    f = C(e, Table.RowCount(e), Table.ColumnNames(e))
 ] [f]}, 0, (x,y)=> Byte.From(y = null))[x],
E = Table.RemoveLastN(Table.Combine(D))
in E

Regards,
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,837
Messages
6,193,249
Members
453,784
Latest member
Chandni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top