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
Kristofferaabo
Helper IV
Helper IV

Tanspose/pivot dataset to get columns instaed of rows

Hi I have a task where I need to calculate days between two 'meetings'. Normally the data I get have this in columns and there wont be a problem. 

 

Is there any wat I can transpose/pivot this so I can do this easier?

 

I have attached an example of the data


Thanks in advance

Kristofferexample_PB.jpg

 

 

1 ACCEPTED SOLUTION

Hi @Kristofferaabo,

 

Click on "Edit Queries" -> "Advanced Editor" and paste this code:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc8xC4MwEAXgvxJuFnJXjdqxg6UgTnVQJKMUlw7V/4/v0kztbXnwveRlWWj4uIkKGtb12N4vF3CW2rP4C0uLMFEs/lSJM0MFVVrpLKV1Lr2wqgZhtJSoavOLNcLjq7Z9d/PPMtzGlTot3W2XtgXPVziuEJ62y+vSH5LrexumgU2G2rpRjCc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Person = _t, #"Type of Meeting" = _t, #"Date of Meeting" = _t, #"Place of Meeting" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Person", type text}, {"Type of Meeting", type text}, {"Date of Meeting", type date}, {"Place of Meeting", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Place of Meeting"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"Type of Meeting"]), "Type of Meeting", "Date of Meeting")
in
#"Pivoted Column"

 

After close and apply.

 

I tried it deleting duplicates (person with more than 1 meeting in the same day).

 

Thanks,

 

Ricardo

View solution in original post

8 REPLIES 8
ricardocamargos
Continued Contributor
Continued Contributor

Hi @Kristofferaabo,

 

How are you gonna calculate it ?

If u use your dataset (attached image) u can use the calculate function to do it.

However I'm not sure if u can do it dinamically unless you link which meeting you wanna compare in a table.

 

Ricardo

So I would like to calculate like this:

 

days(meeting 1.date) - days(meeting 2.date)

 

Does this make sense? 

@Kristofferaabo,

 

Can you provide the visual you would like to build ?

 

Which context would be relevant for days(meeting 1.date) - days(meeting 2.date) ?

 

Tks,

 

Ricardo

Best case I would need it as a column (delta betwwen two meetings) that way I can anaylyze time gaps across the various persons and roll it up to country

Hi @Kristofferaabo,

 

Sorry, I can't visualize it. 

Can you, please, try a demo on Excel ? So I can see how you want visualize your data.

 

Thanks,

 

 Ricardo

thanks for the patience.

 

Something like this

ex_2.jpg

 

 

@Kristofferaabo your requirement is not clear.

 

Is it always K2-J2?

 

What about other dates?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @Kristofferaabo,

 

Click on "Edit Queries" -> "Advanced Editor" and paste this code:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc8xC4MwEAXgvxJuFnJXjdqxg6UgTnVQJKMUlw7V/4/v0kztbXnwveRlWWj4uIkKGtb12N4vF3CW2rP4C0uLMFEs/lSJM0MFVVrpLKV1Lr2wqgZhtJSoavOLNcLjq7Z9d/PPMtzGlTot3W2XtgXPVziuEJ62y+vSH5LrexumgU2G2rpRjCc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Person = _t, #"Type of Meeting" = _t, #"Date of Meeting" = _t, #"Place of Meeting" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Person", type text}, {"Type of Meeting", type text}, {"Date of Meeting", type date}, {"Place of Meeting", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Place of Meeting"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"Type of Meeting"]), "Type of Meeting", "Date of Meeting")
in
#"Pivoted Column"

 

After close and apply.

 

I tried it deleting duplicates (person with more than 1 meeting in the same day).

 

Thanks,

 

Ricardo

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.