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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bposa217
New Member

Help with Transforming Data

I am trying to transition our commission reporting from Excel into Power BI, but I'm having trouble splitting out (and then summing) the margin (commission) based upon the way the data is brought into the model.

 

The data comes in likes this:

MatchIDCreditClientOwnerCreditCandidateOwnerPPEMarginClient SideCandidate Side
142242John SmithGeorge Washington9/29/2019$192.00$96.00$96.00
112560Abraham LincolnAbraham Lincoln9/29/2019$767.13$383.57$383.57
139749George WashingtonAbraham Lincoln9/29/2019$1,063.55$531.78$531.78
151035Abraham LincolnJohn Smith9/29/2019$1,042.94$521.47$521.47

 

But I ultimately need to get it into this type of format/matrix:

RecruiterClient SideCandidate SideTotal
Abraham Lincoln $     905.04 $              915.34 $  1,820.38
John Smith $        96.00 $              521.47 $     617.47
George Washington $     531.78 $                 96.00 $     627.78

 

The biggest problem I have is that there are two names (owners) per row (transaction), so leveraging caculated columns thus far hasn't provided me the breakthrough I'm looking for.  I'm assuming I'm going to need to create a master "Salesperson" table that lists all of the sales team members we have, but I stumble upon the relationship aspect because not all names will necessarily appear in both the client and candidate owner columns.

 

Any help is appreciated!

1 ACCEPTED SOLUTION
VasTg
Memorable Member
Memorable Member

@bposa217 

 

My recommendation for Enterprise architecture would be different but taking a simpler approach for Excel.

 

All right. Here you go.

 

I copied your sample data and created an Entity/Table, changed datatypes, Use first row as Headers..Highlighed in Red Text.

cap13.PNG

 

 

I selected CreditClientOwner and CreditCandidateOwner and hit Unpivot Only selected Columns under Transform ribbon. Highlighted in Blue

 

Created 2 new conditional columns (New Client Side and New Candidate Side) to show corresponding values. Highlighted in green

The final table looks like below.

cap12.PNG

Here is the expected results with new total measure (SUM('Table'[New Candidate Side])+SUM('Table'[New Client Side]))

Cap11.PNG

 

Query Editor Steps:

 

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hZBNi8IwEIb/SikeSzaTj8YcRUWUlRU87KH0EG1oAppCDPj3TbLItouLEIZn3kwewjRNuVfhbLarsiqXXnc2LC9Wu/B1d9r/Zsp1tlNBP+PDYR3rXvneujSV3xRH2+nUPad/grZqSmCEMBLvdoNxxfFqg4nNRg++18W3uhnr+jAklfwg8WCQkWcgCcI4kawnkJ1AeJ2yxckro67Fp3Xn4eJeJhOtqAUCmojOKeJiRFlMpWDyn/+9UUOF6yjiiTkFJOYjynIOmPKXoslu/loZQZJlFwHExIja9gE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t, #"(blank).5" = _t, #"(blank).6" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}, {"(blank).5", type text}, {"(blank).6", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"MatchID", Int64.Type}, {"CreditClientOwner", type text}, {"CreditCandidateOwner", type text}, {"PPE", type date}, {"Margin", Currency.Type}, {"Client Side", Currency.Type}, {"Candidate Side", Currency.Type}}),
#"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type1", {"CreditClientOwner", "CreditCandidateOwner"}, "Attribute", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Unpivoted Only Selected Columns",{{"Attribute", "Client Or Candidate"}, {"Value", "Recruiter"}}),
#"Added Conditional Column" = Table.AddColumn(#"Renamed Columns", "New Client Side", each if [Client Or Candidate] = "CreditClientOwner" then [Client Side] else 0),
#"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "New Candidate Side", each if [Client Or Candidate] = "CreditCandidateOwner" then [Candidate Side] else 0),
#"Changed Type2" = Table.TransformColumnTypes(#"Added Conditional Column1",{{"New Client Side", type number}, {"New Candidate Side", type number}})
in
#"Changed Type2"

 

 

If this helps, Accept it as a solutions.

Kudos are good too.

 

Connect on LinkedIn

View solution in original post

3 REPLIES 3
VasTg
Memorable Member
Memorable Member

@bposa217 

 

My recommendation for Enterprise architecture would be different but taking a simpler approach for Excel.

 

All right. Here you go.

 

I copied your sample data and created an Entity/Table, changed datatypes, Use first row as Headers..Highlighed in Red Text.

cap13.PNG

 

 

I selected CreditClientOwner and CreditCandidateOwner and hit Unpivot Only selected Columns under Transform ribbon. Highlighted in Blue

 

Created 2 new conditional columns (New Client Side and New Candidate Side) to show corresponding values. Highlighted in green

The final table looks like below.

cap12.PNG

Here is the expected results with new total measure (SUM('Table'[New Candidate Side])+SUM('Table'[New Client Side]))

Cap11.PNG

 

Query Editor Steps:

 

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hZBNi8IwEIb/SikeSzaTj8YcRUWUlRU87KH0EG1oAppCDPj3TbLItouLEIZn3kwewjRNuVfhbLarsiqXXnc2LC9Wu/B1d9r/Zsp1tlNBP+PDYR3rXvneujSV3xRH2+nUPad/grZqSmCEMBLvdoNxxfFqg4nNRg++18W3uhnr+jAklfwg8WCQkWcgCcI4kawnkJ1AeJ2yxckro67Fp3Xn4eJeJhOtqAUCmojOKeJiRFlMpWDyn/+9UUOF6yjiiTkFJOYjynIOmPKXoslu/loZQZJlFwHExIja9gE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t, #"(blank).5" = _t, #"(blank).6" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}, {"(blank).5", type text}, {"(blank).6", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"MatchID", Int64.Type}, {"CreditClientOwner", type text}, {"CreditCandidateOwner", type text}, {"PPE", type date}, {"Margin", Currency.Type}, {"Client Side", Currency.Type}, {"Candidate Side", Currency.Type}}),
#"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type1", {"CreditClientOwner", "CreditCandidateOwner"}, "Attribute", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Unpivoted Only Selected Columns",{{"Attribute", "Client Or Candidate"}, {"Value", "Recruiter"}}),
#"Added Conditional Column" = Table.AddColumn(#"Renamed Columns", "New Client Side", each if [Client Or Candidate] = "CreditClientOwner" then [Client Side] else 0),
#"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "New Candidate Side", each if [Client Or Candidate] = "CreditCandidateOwner" then [Candidate Side] else 0),
#"Changed Type2" = Table.TransformColumnTypes(#"Added Conditional Column1",{{"New Client Side", type number}, {"New Candidate Side", type number}})
in
#"Changed Type2"

 

 

If this helps, Accept it as a solutions.

Kudos are good too.

 

Connect on LinkedIn

This worked perfectly!  Thanks for your help.

Thedatadude
Frequent Visitor

Interesting... really excited to see the community answer. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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