Can I unpivot multiple non-contiguous rows to columns?

Mark_E

New Member
Joined
Aug 11, 2016
Messages
14
I am trying to import six regional schedules, each with a separate sheet for each week of the month.
When I pull all of the sheets in through power query the dates are scattered on various rows throughout the aggregated editor view.

Is it possible to unpivot all of the rows with dates to columns? I can only get the initial week to do so, and would prefer not to have to do a separate query to each sheet for each region if possible.

The Date is structured like:

74 Rows later:


PopTaskShiftBreakLunchBreak8/5/198/6/198/7/198/8/198/9/19
AdultsWalk In8-4:3012-12:30FilsanAnnMihiretBasmaGary
ADSPhones8-4:3012-12:30MaiRaeAnnDianaRebeccaScott

<tbody>
</tbody>


54 Rows later:


PopTaskShiftBreakLunchBreak8/5/198/6/198/7/198/8/198/9/19
AdultsWalk In8-4:3012-12:30JoanMelindaRachelNaimaRoberta
ADSPhones8-4:3012-12:30CynthiaSamiraJasonRhondaAnn

<tbody>
</tbody>

I want to end with a list of for example, all Adults Walk-Ins grouped by date, but I am not sure of it is possible with the mess I have.

Thanks,
Mark
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Here is the Mcode using Power Query to unpivot your data.

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Pop", type text}, {"Task", type text}, {"Shift", type text}, {"Break", type any}, {"Lunch", type text}, {"Break2", type any}, {"8/5/2019", type text}, {"8/6/2019", type text}, {"8/7/2019", type text}, {"8/8/2019", type text}, {"8/9/2019", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Pop", "Task", "Shift", "Break", "Lunch", "Break2"}, "Attribute", "Value"),
    #"Reordered Columns" = Table.ReorderColumns(#"Unpivoted Columns",{"Attribute", "Value", "Pop", "Task", "Shift", "Break", "Lunch", "Break2"}),
    #"Sorted Rows" = Table.Sort(#"Reordered Columns",{{"Attribute", Order.Ascending}})
in
    #"Sorted Rows"

This is the end result.

Data Range
A
B
C
D
E
F
G
H
1
Attribute​
Value​
Pop​
Task​
Shift​
Break​
Lunch​
Break2​
2
8/5/2019​
Mai​
ADS​
Phones​
8-4:30​
12-12:30​
3
8/5/2019​
Filsan​
Adults​
Walk In​
8-4:30​
12-12:30​
4
8/6/2019​
RaeAnn​
ADS​
Phones​
8-4:30​
12-12:30​
5
8/6/2019​
Ann​
Adults​
Walk In​
8-4:30​
12-12:30​
6
8/7/2019​
Mihiret​
Adults​
Walk In​
8-4:30​
12-12:30​
7
8/7/2019​
Diana​
ADS​
Phones​
8-4:30​
12-12:30​
8
8/8/2019​
Basma​
Adults​
Walk In​
8-4:30​
12-12:30​
9
8/8/2019​
Rebecca​
ADS​
Phones​
8-4:30​
12-12:30​
10
8/9/2019​
Scott​
ADS​
Phones​
8-4:30​
12-12:30​
11
8/9/2019​
Gary​
Adults​
Walk In​
8-4:30​
12-12:30​

Will this presentation work for you? If not, please show us a mocked up version of what is acceptable.
 
Upvote 0
The post was partially cutoff, and without the ability to attach an attachment or picture to the post, I unfortunately can't provide a good mock up.

Let me retry.

PopTask8/68/78/88/98/10
AdultsWalkinname1name2name3name4name5
ADSphonesname6name7name8name9name10

<tbody>
</tbody>

54 rows later
PopTask8/138/148/158/168/17
AdultsWalkinname11name12name13name14name15
ADSphonesname16name17name18name19name20

<tbody>
</tbody>


74 rows after that:
PopTask8/208/218/228/238/24
AdultsWalkinname21name22name23name24name25
ADSphonesname26name27name28name29name30

<tbody>
</tbody>

repeat in 63 rows for the next week, and then again in varying row amounts for each of the 6 regions.

I can get the unpivot shown, but what I badly asked and didn't show correctly was can I get the other weeks to unpivot too, because whatever I try I just get the first week.

Thanks,
Mark
 
Upvote 0
I am having a hard time with this editor :/ Apologies for not asking this correctly.

PopTask8/58/68/78/88/9
AdultsWalkinsname1name2name3name4name5
ADSphonesname6name7name8name9name10

<tbody>
</tbody>




74 Rows later:


PopTask8/128/138/148/158/16
AdultsWalkinsname11name12name13name14name15
ADSphonesname16name17name18name19name20

<tbody>
</tbody>



54 Rows later:


PopTask8/178/188/198/208/21
AdultsWalkinsname21name22name23name24name25
ADSphonesname26name27name28name29name30

<tbody>
</tbody>

65 rows later:

PopTask8/248/258/268/278/28
AdultsWalkinsname21name22name23name24name25
ADSphonesname26name27name28name29name30

<tbody>
</tbody>


repeat at various row counts for each region. Is it possible to get the other weeks to unpivot as well, because all I can do is get the first week's dates to unpivot.


That is the type of presentation I am looking for though. I need to get a list of names and tasks by date so I can add an index to match to additional data in a different query.

Thanks,
 
Last edited:
Upvote 0
I don't understand your requirement. Why not list the whole range of data and unpivot it. I seem to be missing something here.
 
Upvote 0
@Mark_E

Can you use the insert link feature ( the globe next to the smiley face) to share a picture of what the results should look like in excel?

Should the original data look like this?


Book1
ABCDEFG
1PopTask6-Aug7-Aug8-Aug9-Aug10-Aug
2AdultsWalkinname1name2name3name4name5
3ADSphonesname6name7name8name9name10
4
5
6
7PopTask13-Aug14-Aug15-Aug16-Aug17-Aug
8AdultsWalkinname11name12name13name14name15
9ADSphonesname16name17name18name19name20
10
11
12
13
14PopTask20-Aug21-Aug22-Aug23-Aug24-Aug
15AdultsWalkinname21name22name23name24name25
16ADSphonesname26name27name28name29name30
Sheet5
 
Last edited:
Upvote 0
simply post a link to the shared (OneDrive, GoogleDrive, DropBox or any similar) excel file with representative example of the source data and expected result
 
Last edited:
Upvote 0
Sorry for the delay, I had a family funeral and then have been getting caught back up.

Here is a link to the file.
https://drive.google.com/open?id=1Cbcc0HkN8HMT30OhhbcswIkQIg9KQjhT

Here is a picture of what I am trying to get to.
https://drive.google.com/open?id=1YG4N4iAyPPzMvS-IBHWCUT5oeJfT4TlM

open

I can get this output, but only with dates for the first week. I am trying to get this output for all sheets (each sheet is a week). As it is, I get all the workers, but the dates are incorrect.
 
Upvote 0
I had a family funeral.
Very sorry.

---
from your picture I can see transform for ADS Processing. It's ok? or post representative (manually created) expected result.
and you want this ADS Processing from all sheets into one table?
 
Upvote 0
She was 94. It was sad because she was loved, but not tragic. Thank you for your sympathies.
 
Upvote 0

Forum statistics

Threads
1,213,490
Messages
6,113,957
Members
448,535
Latest member
alrossman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top