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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
pect
Helper I
Helper I

Table transformation

Dear all,

 

I would like to transform a table in Power BI but I don't find the way to do it. I will clarify my doubt with an example.

 

1) I load in Power BI  a table like the following:

 

Project

Recruiting amount year X

Awarded amount year X

Contracting amount year Y

Awarded amount year Y

1

A

C

E

G

2

B

D

F

H

 

2) I would like to transform it in order to obtain the following table:

 

Project

Recruitment statusYear

Amount

1

Recruiting

X

A

1

Recruiting

Y

E

1

Awarded

X

C

1

Awarded

Y

G

2

Recruiting

X

B

2

Recruiting

Y

F

 

Could anyone shed a light?

 

Thank you very much.

1 ACCEPTED SOLUTION

This query:

 

let
    Source = Table1,
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Project"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Recruitment status"}, {"Value", "Amount"}}),
    #"Inserted Text After Delimiter" = Table.AddColumn(#"Renamed Columns", "Year", each Text.AfterDelimiter([Recruitment status], " ", {0, RelativePosition.FromEnd}), type text),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Inserted Text After Delimiter", {{"Recruitment status", each Text.BeforeDelimiter(_, " ", 0), type text}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Extracted Text Before Delimiter",{"Project", "Recruitment status", "Year", "Amount"})
in
    #"Reordered Columns"

 

Results in:

Table Transformation.png

Specializing in Power Query Formula Language (M)

View solution in original post

4 REPLIES 4
MarcelBeug
Community Champion
Community Champion

Can you explain the logic?

 

E.g. how does amount E from column Contracting amount year Y end up with recruitment status Recruitment?

Specializing in Power Query Formula Language (M)

This query:

 

let
    Source = Table1,
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Project"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Recruitment status"}, {"Value", "Amount"}}),
    #"Inserted Text After Delimiter" = Table.AddColumn(#"Renamed Columns", "Year", each Text.AfterDelimiter([Recruitment status], " ", {0, RelativePosition.FromEnd}), type text),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Inserted Text After Delimiter", {{"Recruitment status", each Text.BeforeDelimiter(_, " ", 0), type text}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Extracted Text Before Delimiter",{"Project", "Recruitment status", "Year", "Amount"})
in
    #"Reordered Columns"

 

Results in:

Table Transformation.png

Specializing in Power Query Formula Language (M)

Thank you very much Marcel.

 

It worked with the example I have given. However, I am trying to adapt the query in case there was any modification of the input table. For example, my real input table is:

 

PlaConcepteEstatCodi ActuacióLínia pressupostSubplaNom2017 moviment2017 adjudicat2017 licitació2018 moviment2018 adjudicat2018
licitació
2019 moviment2019 adjudicat2019 licitacióData extracció
Pla TecnològicLínia BaseLínia Base AM XF  H     09/10/2017
Pla TecnològicContracteAdjudicat BN Y G  I    09/10/2017

 

Therefore, the table I would like to obtain would be:

 

Capture2.PNG

 

I would really appreciate if you could help me with my real example.

 

Thank you again!

 

Sorry,

 

I insert again the input table as I see it is not clear.

 

Capture3.PNG

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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