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
ashikts
Helper II
Helper II

data transformation

hi sir,

yesterday you have replied to one of my query yesterday . But that was not enough for me .

Please help to solve it .

I will explain again.

employee-projecthours casted
ashik48
pbi40
java8
rahul48
java32
php32
personal leave8
holiday8
amit40
sql32
holiday8
  

our one table ;ike this with diffrent employee name and their project wise time allocation and holiday or leave allocation.

we have another table 

 

employee total casted hoursempid
ashik48ina101
rahul48ina504
amit40

 

 

 

result i want is . Please help me sir.im new to this department 

 

employeeholiday hourspersonal leave hours
ashik80
rahul88
amit80
1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @ashikts ,

some fill-down and pivot-magic should do the trick:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSizOyMxW0lEysVCK1YlWKkjKBHEMwJysxLJEIA8iU5SYUZqDUAiVMzaCaMsoQOKkFhXn5yXmKOSkJpalwg3IyM/JTEmshPMTczNLEHYVF+YgTEBRGgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"employee-project" = _t, #"hours casted" = _t]),
    EmployessTable = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSizOyMxW0lEysQASmXmJhgaGSrE60UpFiRmlOUjipgYmYPHE3MwSkLABkFCKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"employee " = _t, #"total casted hours" = _t, empid = _t]),
    #"Merged Queries" = Table.NestedJoin(Source, {"employee-project"}, EmployessTable, {"employee "}, "EmployessTable", JoinKind.LeftOuter),
    #"Expanded EmployessTable" = Table.ExpandTableColumn(#"Merged Queries", "EmployessTable", {"employee "}, {"employee "}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded EmployessTable",{{"hours casted", type number}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "employee ", "employee  - Copy"),
    #"Filled Down" = Table.FillDown(#"Duplicated Column",{"employee "}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([#"employee  - Copy"] = null)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"employee  - Copy"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"employee-project"]), "employee-project", "hours casted", List.Sum)
in
    #"Pivoted Column"

Please also check the attached file.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

3 REPLIES 3
ImkeF
Community Champion
Community Champion

Hi @ashikts ,

some fill-down and pivot-magic should do the trick:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSizOyMxW0lEysVCK1YlWKkjKBHEMwJysxLJEIA8iU5SYUZqDUAiVMzaCaMsoQOKkFhXn5yXmKOSkJpalwg3IyM/JTEmshPMTczNLEHYVF+YgTEBRGgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"employee-project" = _t, #"hours casted" = _t]),
    EmployessTable = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSizOyMxW0lEysQASmXmJhgaGSrE60UpFiRmlOUjipgYmYPHE3MwSkLABkFCKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"employee " = _t, #"total casted hours" = _t, empid = _t]),
    #"Merged Queries" = Table.NestedJoin(Source, {"employee-project"}, EmployessTable, {"employee "}, "EmployessTable", JoinKind.LeftOuter),
    #"Expanded EmployessTable" = Table.ExpandTableColumn(#"Merged Queries", "EmployessTable", {"employee "}, {"employee "}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded EmployessTable",{{"hours casted", type number}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "employee ", "employee  - Copy"),
    #"Filled Down" = Table.FillDown(#"Duplicated Column",{"employee "}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([#"employee  - Copy"] = null)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"employee  - Copy"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"employee-project"]), "employee-project", "hours casted", List.Sum)
in
    #"Pivoted Column"

Please also check the attached file.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

amitchandak
Super User
Super User

@ashikts , that is the issue, there is no way to differentiate between employee name and other names.

 

@ImkeF , Any solution to this problem. Mixed data employee and metrics are in the same column.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@ImkeF @amitchandak  thanks sir. It worked .it was very helpful

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.