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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
jcastr02
Post Prodigy
Post Prodigy

Move from multiple rows to single row

How can I get the attribute column into one row when there are multipe rows relating to the same index....see below current and desired result.

 

Current     
Act_DtIndexReportingMonthAttributeValueCountType
9/26/202479/1/2024pwr_activity_cd_close1POWER
9/26/202479/1/2024pwr_activity_cd_deleted1POWER
      
DESIRED     
Act_DtIndexReportingMonthAttributeValueCountType
9/26/202479/1/2024pwr_activity_cd_close; pwr_activity_cd_deleted1POWER
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

lbendlin_0-1735315104275.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstQ3MtM3MjAyUdJRMgdiS31DGLegvCg+MbkksyyzpDI+OSU+OSe/OBUobgjEAf7hrkFKsTokGZCSmpNakpqCakQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Act_Dt = _t, Index = _t, ReportingMonth = _t, Attribute = _t, Value = _t, CountType = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Act_Dt", "Index", "ReportingMonth", "Value", "CountType"}, {{"Attribute", each Text.Combine([Attribute],"; "), type nullable text}})
in
    #"Grouped Rows"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

lbendlin_0-1735315104275.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstQ3MtM3MjAyUdJRMgdiS31DGLegvCg+MbkksyyzpDI+OSU+OSe/OBUobgjEAf7hrkFKsTokGZCSmpNakpqCakQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Act_Dt = _t, Index = _t, ReportingMonth = _t, Attribute = _t, Value = _t, CountType = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Act_Dt", "Index", "ReportingMonth", "Value", "CountType"}, {{"Attribute", each Text.Combine([Attribute],"; "), type nullable text}})
in
    #"Grouped Rows"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.

dufoq3
Super User
Super User

Hi @jcastr02, check this:

 

Output

dufoq3_0-1735314988111.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstQ3MtM3MjAyUdJRMgdiS31DGLegvCg+MbkksyyzpDI+OSU+OSe/OBUobgjEAf7hrkFKsTokGZCSmpNakpqCakQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Act_Dt = _t, Index = _t, ReportingMonth = _t, Attribute = _t, Value = _t, CountType = _t]),
    GroupedRows = Table.Group(Source, {"Index"}, {{"T", each Table.FromRecords({Table.First(Table.RemoveColumns(_, {"Attribute"})) & [Attribute = Text.Combine([Attribute], "; ") ]}) , type table}}, 0),
    Combined = Table.Combine(GroupedRows[T], Value.Type(Table.FirstN(Source,0)))
in
    Combined

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.