Formula problem and a pivot does not help...please can you?

dollyann

Board Regular
Joined
Jan 26, 2011
Messages
61
Hi

I have an excel query and i can not figure it out:

I have a list of names in column A and Dates along in Row 1. And under the dates by the names are zeros or BH (Bank Holiday), W (worked), H (Hol) & HF (Half Day Hol)

I am trying to get results by looking at the name i want to know when they have holiday (H) or half day holiday (HF)and to give me the date

For Example:

My Table look like:

01/01/19 02/01/2019 03/01/2019 04/01/2019
Tony H W 0 H
John 0 0 0 HF
Sarah 0 0 HF 0
David H H H H
Steve 0 0 0 0

And i would like my results to look like:

Tony 01/01/19, 04/01/2019
John 04/01/19
Sarah 03/01/19
David 01/01/19,02/01/19, 03/01/19, 04/01/19
Steve

I have tried pivot table and just can't get it to work :( Does anybody have any ideas to help me

Really appriecate any help.... Please!! :)
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
if you have PowerQuery (Get&Transform) you can try this

Name01/01/201902/01/201903/01/201904/01/2019NameDate.1Date.2Date.3Date.4
TonyHW
0​
HTony
01/01/2019​
04/01/2019​
John
0​
0​
0​
HFJohn
04/01/2019​
Sarah
0​
0​
HF
0​
Sarah
03/01/2019​
DavidHHHHDavid
01/01/2019​
02/01/2019​
03/01/2019​
04/01/2019​
Steve
0​
0​
0​
0​
Mark
01/01/2019​
04/01/2019​
MarkHWH

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table20"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Name"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] = "H" or [Value] = "HF")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Name"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Date", each Table.Column([Count],"Attribute")),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Date", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values",{"Count"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns", "Date", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Date.1", "Date.2", "Date.3", "Date.4"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Date.1", type date}, {"Date.2", type date}, {"Date.3", type date}, {"Date.4", type date}})
in
    #"Changed Type"[/SIZE]
 
Upvote 0
if you have PowerQuery (Get&Transform) you can try this

[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Name[/COLOR]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]01/01/2019[/COLOR]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]02/01/2019[/COLOR]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]03/01/2019[/COLOR]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]04/01/2019[/COLOR]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Name[/COLOR]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Date.1[/COLOR]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Date.2[/COLOR]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Date.3[/COLOR]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Date.4[/COLOR]
Tony
H
W

0​
H
Tony

01/01/2019​

04/01/2019​
John

0​

0​

0​
HF
John

04/01/2019​
Sarah

0​

0​
HF

0​
Sarah

03/01/2019​
David
H
H
H
H
David

01/01/2019​

02/01/2019​

03/01/2019​

04/01/2019​
Steve

0​

0​

0​

0​
Mark

01/01/2019​

04/01/2019​
Mark
H
W
H

<tbody>
</tbody>


Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table20"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Name"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] = "H" or [Value] = "HF")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Name"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Date", each Table.Column([Count],"Attribute")),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Date", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values",{"Count"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns", "Date", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Date.1", "Date.2", "Date.3", "Date.4"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Date.1", type date}, {"Date.2", type date}, {"Date.3", type date}, {"Date.4", type date}})
in
    #"Changed Type"[/SIZE]



Hi, thank you for responding, I don't have Power Query, and sadly i don't know how to write code. I am just basic Excel :( Ay our thoughts which cold help me? or am I asking the impossible?? :(
 
Upvote 0
Almost everything is possible in excel :)

PowerQuery add-in Excel 2010/2013
PowerQuery aka Get&Transform built-in Excel 2016 and higher

you need to wait for someone else for solution different than PQ

Have a nice day
 
Upvote 0
may be


Book1
ABCDE
101/01/201902/01/201903/01/201904/01/2019
2TonyHW0H
3John000HF
4Sarah00HF0
5DavidHHHH
6Steve0000
7
8
9Tony01/01/201904/01/2019
10John04/01/2019
11Sarah03/01/2019
12David01/01/201902/01/201903/01/201904/01/2019
13Steve
Sheet8
Cell Formulas
RangeFormula
B9{=IFERROR(SMALL(IF((INDEX($B$2:$E$6,MATCH($A9,$A$2:$A$6,0),)="H")+(INDEX($B$2:$E$6,MATCH($A9,$A$2:$A$6,0),)="HF"),$B$1:$E$1),COLUMN(B$1)-COLUMN($B$1)+1),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
ok, almost black and almost sugar please

sure,

giphy.gif
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,718
Members
448,986
Latest member
andreguerra

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