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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
roscas
Helper I
Helper I

Convert Rows in Columns

I need to convert rows to Columns. If you see the picture on the left, I have the data on the right of the result, could someone please help me with this?

PQ 1.png

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@roscas 

or if you prefer to do this in PQ, you can pivot the Salary type column:

AlB_1-1673423439435.png

and choose Amount as the values column:

AlB_2-1673423540941.png

See it all at work in the attached file. (OutputT is the version in PQ)

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

6 REPLIES 6
AlB
Community Champion
Community Champion

@roscas 

or if you prefer to do this in PQ, you can pivot the Salary type column:

AlB_1-1673423439435.png

and choose Amount as the values column:

AlB_2-1673423540941.png

See it all at work in the attached file. (OutputT is the version in PQ)

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

AlB
Community Champion
Community Champion

@roscas 

I misunderstood. Thought your input was your output.  In that case, you can:

1. Place ID, Name and Status in a table visual

2. Create these two measures and place them in the table visual:  

Actual = 
CALCULATE ( SUM ( InputT[Amount] ), InputT[Salary type] = "Actual" )
Benefit = 
CALCULATE ( SUM ( InputT[Amount] ), InputT[Salary type] = "Benefit" )

The result will look like:

AlB_0-1673423187160.png

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Hi thanks for your help, the solutions (formulas) are created on DAX? 

Is there a solution to do on M (Power Query)? Thanks

AlB
Community Champion
Community Champion

@roscas 


@roscas wrote:

Is there a solution to do on M (Power Query)? Thanks


looks like you have not seen my other message,  have you?

 


SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

AlB
Community Champion
Community Champion

Hi @roscas 

Just select the two columns (Actual and Benefit) and unpivot them. Then change column names as required

Place the following M code in a blank query to see the steps.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJLzE0F0Y7JJZllqUCGkYEBkDQGkrE60UpGUCVGyErMjUFKzIwhSoyhSoyRlZgagZQAFcQCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t, Status = _t, Actual = _t, Benefit = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}, {"Status", type text}, {"Actual", Int64.Type}, {"Benefit", Int64.Type}}),

    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ID", "Name", "Status"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Salary type"}, {"Value", "Amount"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"ID", "Name", "Status", "Amount", "Salary type"})
in
    #"Reordered Columns"

 

 

AlB_1-1673380830915.png

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Hi thanks for your prompt response, but I didn't get it, I have 

 

from this data

PQ3.png

 I need a Final Table like:

PQ2.png

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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