Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

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

4 Replies

  • Aron_Moore's avatar
    Aron_Moore
    Solution Specialist

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

     

     

    In query editor

    Result:

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      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... :(