Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

New Colum with Facility names

Hello, 

 

I have something in need help with. 

 

I have a table that shows the facility name on top, ant then list the items. then on the same table it shows the next facility name and list the items of that facility again, as shown in the picture

 

I like to have the facility name in each row, but don't know how to do it. 

 

Thank you in advance for any help iIcan get.

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @Syndicate_Admin 

You can put the following code to advanced editor in power query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("1ZDBasMwDIZfxeRcllhZ2XYsdDttoYexS+hBUZTWsDbBccry9pNSOm9ljFwHRkj25x/xlWXyhOTeXRiTRbLh2mHwjnqzWckcz3ZRJs9tMK9jxzKvKLgT/0oUw6FiLzdvSOSObAo8KPnt9wsehwYpDH4CHz8650ezxqCPRXvTNmbd9txPmSh3qOXUkFRFIAObQmrvpLfZRFXSVlq6wdMee66lb87srbJZZDWG6Ctxd6GWaW4jpQF1fZW4v7AWUriPsG7FfL3kUiIhj9QP0z6qRgP/QzbMkZ2fNcLfskXhQ6TmyYZZspXafgI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Facility name", each if [Column1] = "Facility" then [Column2] else null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Lot Type", each if [Column1]="Lot Type" then [Column2] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom1",{"Facility name"}),
    #"Filled Down1" = Table.FillDown(#"Filled Down",{"Lot Type"}),
    #"Filled Up" = Table.FillUp(#"Filled Down1",{"Lot Type"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Up", each ([Column1] <> "Facility" and [Column1] <> "Lot Type")),
    #"Promoted Headers" = Table.PromoteHeaders(#"Filtered Rows", [PromoteAllScalars=true]),
    #"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",{{"Pediatrics PA", "Facility name"}, {"Active", "Status"}}),
    #"Filtered Rows1" = Table.SelectRows(#"Renamed Columns", each ([Lot Number] <> "Lot Number")),
    #"Reordered Columns" = Table.ReorderColumns(#"Filtered Rows1",{"Facility name", "Status", "Lot Number", "Vaccine Name", "Lot Type", "Manufacturer", "Expiry Date", "No.of Doses"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Reordered Columns",{{"Expiry Date", type date}, {"No.of Doses", Int64.Type}})
in
    #"Changed Type1"

Output

vxinruzhumsft_0-1702619880299.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @Syndicate_Admin 

You can put the following code to advanced editor in power query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("1ZDBasMwDIZfxeRcllhZ2XYsdDttoYexS+hBUZTWsDbBccry9pNSOm9ljFwHRkj25x/xlWXyhOTeXRiTRbLh2mHwjnqzWckcz3ZRJs9tMK9jxzKvKLgT/0oUw6FiLzdvSOSObAo8KPnt9wsehwYpDH4CHz8650ezxqCPRXvTNmbd9txPmSh3qOXUkFRFIAObQmrvpLfZRFXSVlq6wdMee66lb87srbJZZDWG6Ctxd6GWaW4jpQF1fZW4v7AWUriPsG7FfL3kUiIhj9QP0z6qRgP/QzbMkZ2fNcLfskXhQ6TmyYZZspXafgI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Facility name", each if [Column1] = "Facility" then [Column2] else null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Lot Type", each if [Column1]="Lot Type" then [Column2] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom1",{"Facility name"}),
    #"Filled Down1" = Table.FillDown(#"Filled Down",{"Lot Type"}),
    #"Filled Up" = Table.FillUp(#"Filled Down1",{"Lot Type"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Up", each ([Column1] <> "Facility" and [Column1] <> "Lot Type")),
    #"Promoted Headers" = Table.PromoteHeaders(#"Filtered Rows", [PromoteAllScalars=true]),
    #"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",{{"Pediatrics PA", "Facility name"}, {"Active", "Status"}}),
    #"Filtered Rows1" = Table.SelectRows(#"Renamed Columns", each ([Lot Number] <> "Lot Number")),
    #"Reordered Columns" = Table.ReorderColumns(#"Filtered Rows1",{"Facility name", "Status", "Lot Number", "Vaccine Name", "Lot Type", "Manufacturer", "Expiry Date", "No.of Doses"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Reordered Columns",{{"Expiry Date", type date}, {"No.of Doses", Int64.Type}})
in
    #"Changed Type1"

Output

vxinruzhumsft_0-1702619880299.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

wdx223_Daniel
Super User
Super User

NewStep=Table.SplitColumn(Table.FromPartitions("x",Table.Group(YourTable,"Column1",{"n",each {[Column2]{0}&","&[Column2]{1},Table.PromoteHeaders(Table.Skip(_,2))}},0,(x,y)=>Byte.From(y="Facility"))[n]),"x",each Text.Split(_,","),{"Facility","Lot Type"})

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors