Reply
Regular Visitor
Posts: 15
Registered: ‎12-08-2016
Accepted Solution

Unpivoting?

Hi all! I've been scratching my head with the following modeling issue... I am importing a Sharepoint List of employees located in different sites... The structure of this list is:

- one site per row

- up to 32 groups of columns with details for up to 32 employes on each site:

  • Staff1_Name, Staff1_Email, Staff1_tel, Staff1_job,
  • Staff2_Name, Staff2_Email, Staff2_tel, Staff2_job...

I'd need to "somehow" modify the query so that I would end up with the following structure:

- one site+employee per row

- up to 32 rows for one site

- One colum for name, one for Tel, one for email, one for Job, and one as Staff#

 

Any idea? The worst that came to my mind is to duplicate 32 times this initial query, keeping only one Staff in each duplicated query, and then merge back the 32 queries... pretty weird, right?

 

Thx for your inputs,

Ben

Capture.JPG


Accepted Solutions
Super User
Posts: 1,653
Registered: ‎05-10-2016

Re: Unpivoting?

[ Edited ]

@Benjamin_C

 

Hi, Try with a combination of Unpivot & Pivot.

 

Check the PBIX.

 

PD: If you want to mantain the Staff 1,2,3...

 

Do This:

 

Staff.png

 

 

Regards

 

Victor




Lima - Peru
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




View solution in original post

Attachment

All Replies
Member
Posts: 100
Registered: ‎07-18-2017

Re: Unpivoting?

Unpivot should get you real close. Using a sample dummy set I selected all non-site columns and click unpivot. Viola!

 

Capture.PNG

 

In query editor

Capture1.PNG

Result:

Capture2.PNG

 

 

Highlighted
Regular Visitor
Posts: 15
Registered: ‎12-08-2016

Re: Unpivoting?

Hi Aron,

thx for your input, but it doesn't solve the issue I'm afraid, as this puts for instance for Staff1 the attributes in different rows, whereas we want them in column... Smiley Sad

Super User
Posts: 1,653
Registered: ‎05-10-2016

Re: Unpivoting?

[ Edited ]

@Benjamin_C

 

Hi, Try with a combination of Unpivot & Pivot.

 

Check the PBIX.

 

PD: If you want to mantain the Staff 1,2,3...

 

Do This:

 

Staff.png

 

 

Regards

 

Victor




Lima - Peru
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




Attachment
Regular Visitor
Posts: 15
Registered: ‎12-08-2016

Re: Unpivoting?

Vvelarde, this is exactly it, thx!!!!!!!