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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
inglexjc
Post Patron
Post Patron

Multiple rows into one row

I have a table that has case ID  (same id showing up in multiple rows) listing what program they receive in different rows.  I'm wanting to be able to show that a case is receiving multiple programs and what those programs are. I think the easiest way would to combine the rows for each case into one row instead of multiple.

 

Example below of how it's coming in:

 

CS_IDHIGH_LEVEL_PGMLOW_LEVEL_PGMCS_STS_CDPGM_STS_CD
1SNAPSNAPOPAP
1Medical AssistanceMAGI AdultOPAP
2Medical AssistanceSSI MandatoryOPAP
3Medical AssistanceSSI MandatoryOPAP
2Medical AssistanceQMBOPAP
3SNAPSNAPOPAP
2Adult FinancialOAP AOPAP
4Adult FinancialOAP AOPAP
3Adult FinancialOAP AOPAP
5Medical AssistanceOAP Med-AOPAP
5Adult FinancialOAP AOPAP
5SNAPSNAPOPAP
6Medical AssistanceOAP Med-AOPAP
7Medical AssistanceSSI MandatoryOPAP
8Medical AssistanceQMBOPAP
9Medical AssistanceQMBOPAP
8Medical AssistanceSSI MandatoryOPAP
8SNAPSNAPOPAP
7Medical AssistanceQMBOPAP
7SNAPSNAPOPAP

 

 

How I'd like it:

CS_IDHIGH_LEVEL_PGMLOW_LEVEL_PGMCS_STS_CDPGM_STS_CD
1SNAPMAGI AdultOPAP
2SSI MandatoryQMBOPAP
3SNAPOAPOPAP
4 REPLIES 4
inglexjc
Post Patron
Post Patron

Case ID represents a client.  I need to show how many programs the client is receiving.  Since the each program creates a new row it makes it difficult to show in one row what programs the client receives.

 

I want all the info for the client to show in one row, instead of multiple rows.

Anonymous
Not applicable

Hi @inglexjc ,

 

You can paste my code as below into advanced editor to learn more details.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQr2cwxAUP4gAsiK1YHI+qamZCYn5ig4FhdnFpck5iWnggQd3T0VHFNKc0rQdBjh0hEc7Kngm5iXkliSX1SJpsmYHE04bQr0dcJiPm5PggwCe0XBLTMPaEZmYg5IhWOAgiOaShOiVRoTrdIUlzdAioESutg0EG80bm+bkWqxOTmxZEF8LFkSrxSnqYScgjs4cPoO03Zz3AbFAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CS_ID = _t, HIGH_LEVEL_PGM = _t, LOW_LEVEL_PGM = _t, CS_STS_CD = _t, PGM_STS_CD = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"CS_ID", Int64.Type}, {"HIGH_LEVEL_PGM", type text}, {"LOW_LEVEL_PGM", type text}, {"CS_STS_CD", type text}, {"PGM_STS_CD", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Combine HIGH_LEVEL_PGM", each Text.Combine(
let _id = [CS_ID]
in
Table.SelectRows(#"Changed Type",each [CS_ID] = _id)[HIGH_LEVEL_PGM]," / ")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Combine LOW_LEVEL_PGM", each Text.Combine(
let _id = [CS_ID]
in
Table.SelectRows(#"Changed Type",each [CS_ID] = _id)[LOW_LEVEL_PGM]," / ")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"HIGH_LEVEL_PGM", "LOW_LEVEL_PGM"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Columns")
in
    #"Removed Duplicates"

Result is as below.

vrzhoumsft_0-1681896394204.png

 

Best Regards,
Rico Zhou

 

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

That did give me: 

inglexjc_0-1681912013959.png

 

How ever it changed my cs_id numbers and narrowed my data down and isn't accurate.

This is just a small snip it of the data.  There are over 2,000 cases.

 

inglexjc_1-1681912226729.png

Notice how cases can have more than one program associated with it, that's why it's listed more than once.  I'd like it all to show on one line so I can show what Longer Term Care case has other programs associated with it.

latimeria
Solution Specialist
Solution Specialist

Hi @inglexjc ,

 

Not clear what you want.
id 1 : high from first row? low from last row?
id 2: SSI mandatory : where does it come from?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors