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
Zal
Regular Visitor

Create Table from

Hi,

 

This is my first post. I'm trying to create a table from the "starting point" to the "Final" below.

Could you guide. I've tried adding a count column and do an unpivot/Pivot. Nothing is working.

If you have any idea that would be great.

 

Starting point

SalesAccountRole
JulienAccount 1Inside Sales
JulienAccount 2Inside Sales
MichaelAccount 1Territory Sales
MichaelAccount 2Territory Sales
MichaelAccount 3Territory Sales

  

Final

AccountInside SalesTerritory Sales
Account 1JulienMichael
Account 2JulienMichael
Account 3 Michael
1 ACCEPTED SOLUTION

@Greg_Deckler Thanks a lot. That answer to my question.

 

Regards

Zal

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

Hooray!! I think I finally figured one of these out!! @ImkeF are you proud of me!?!?

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8irNyUzNU9JRckxOzi/NK1EwBLI984ozU1IVghNzUouVYnWwqDLCpso3MzkjMTUHzbCQ1KKizJL8okq8Ko2IVmmMTWUsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Sales = _t, Account = _t, Role = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Sales", type text}, {"Account", type text}, {"Role", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Role]), "Role", "Sales")
in
    #"Pivoted Column"

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thanks a lot. That answer to my question.

 

Regards

Zal

Definitely 😉

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

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.