Get and Transform - changing/finding value if blank

cmcreynolds

Active Member
Joined
May 21, 2015
Messages
295
Hello, I hope everyone is well. Long time, no post :)

I receive non-normalized data from our field staff who are in teams of 2. For our final analysis, we choose only the team lead (indicated in its own field/column as TL). However, on rare occasion, they leave their response blank and we need to consider the other team member's response.

The issue is there are 82 fields to consider (not my structure, btw). I could come up with an approach if there were only a handful of fields, but writing 82 IF statements would drive me quite bonkers.

I use Get and Transform to extract the data from various folders and I was hoping the solution could be used there. But I could only find a way to replace variables one column at a time.

Here's a short version of how the data is set up.

[TABLE="width: 500"]
<tbody>[TR]
[TD]SiteCode
[/TD]
[TD]TeamLead
[/TD]
[TD]Q1
[/TD]
[TD]Q2
[/TD]
[TD]Q3
[/TD]
[TD]Q4
[/TD]
[/TR]
[TR]
[TD]033
[/TD]
[TD]TL
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]5
[/TD]
[/TR]
[TR]
[TD]033
[/TD]
[TD]NL
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]5
[/TD]
[/TR]
[TR]
[TD]151
[/TD]
[TD]TL
[/TD]
[TD]99
[/TD]
[TD]2
[/TD]
[TD]4
[/TD]
[TD]4
[/TD]
[/TR]
[TR]
[TD]151
[/TD]
[TD]NL
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]3
[/TD]
[/TR]
[TR]
[TD]222
[/TD]
[TD]TL
[/TD]
[TD]4
[/TD]
[TD]99
[/TD]
[TD]1
[/TD]
[TD]1
[/TD]
[/TR]
[TR]
[TD]222
[/TD]
[TD]NL
[/TD]
[TD]2
[/TD]
[TD]4
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[/TR]
[TR]
[TD]167
[/TD]
[TD]TL
[/TD]
[TD]99
[/TD]
[TD]0
[/TD]
[TD]99
[/TD]
[TD]99
[/TD]
[/TR]
[TR]
[TD]167
[/TD]
[TD]NL
[/TD]
[TD]1
[/TD]
[TD]3
[/TD]
[TD]2
[/TD]
[TD]2
[/TD]
[/TR]
</tbody>[/TABLE]


Basically, whenever a TL has a '99' we look at the NL's response. Example: For Q1, site 151, we would want a '1' in the final data set

Again, I have 82 fields to apply this to.

(I looked at 'Group By' and it seemed daunting, I was hoping there was functionality I was overlooking - either in PowerQuery or PowerPivot)

Thank you!
Clifton
 
there will be any number, different or always the same (in yellow fields) or they will be blank?

However, on rare occasion, they leave their response blank and we need to consider the other team member's response.

what max number is proper (I assume not 99 :) )
 
Last edited:
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
try this

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#70AD47]SiteCode[/td][td=bgcolor:#70AD47]TeamLead[/td][td=bgcolor:#70AD47]Q1[/td][td=bgcolor:#70AD47]Q2[/td][td=bgcolor:#70AD47]Q3[/td][td=bgcolor:#70AD47]Q4[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]033[/td][td=bgcolor:#E2EFDA]TL[/td][td=bgcolor:#E2EFDA]
1​
[/td][td=bgcolor:#E2EFDA]
2​
[/td][td=bgcolor:#E2EFDA]
3​
[/td][td=bgcolor:#E2EFDA]
5​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]151[/td][td]TL[/td][td]
1​
[/td][td]
2​
[/td][td]
4​
[/td][td]
4​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]222[/td][td=bgcolor:#E2EFDA]TL[/td][td=bgcolor:#E2EFDA]
4​
[/td][td=bgcolor:#E2EFDA]
4​
[/td][td=bgcolor:#E2EFDA]
1​
[/td][td=bgcolor:#E2EFDA]
1​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]167[/td][td]TL[/td][td]
1​
[/td][td]
0​
[/td][td]
2​
[/td][td]
2​
[/td][/tr]
[/table]


Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"SiteCode", type text}}),
    #"Filled Up" = Table.FillUp(#"Changed Type",{"Q1", "Q2", "Q3", "Q4"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Up", each ([TeamLead] = "TL"))
in
    #"Filtered Rows"[/SIZE]

the assumption is that 99 means blank as you wrote in the first post
 
Upvote 0
Yes, 99 is blank. Thank you.

try this

[TABLE="class: head"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]SiteCode[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]TeamLead[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Q1[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Q2[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Q3[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Q4[/COLOR][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #E2EFDA"]033[/TD]
[TD="bgcolor: #E2EFDA"]TL[/TD]
[TD="bgcolor: #E2EFDA"]
1​
[/TD]
[TD="bgcolor: #E2EFDA"]
2​
[/TD]
[TD="bgcolor: #E2EFDA"]
3​
[/TD]
[TD="bgcolor: #E2EFDA"]
5​
[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]151[/TD]
[TD]TL[/TD]
[TD]
1​
[/TD]
[TD]
2​
[/TD]
[TD]
4​
[/TD]
[TD]
4​
[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #E2EFDA"]222[/TD]
[TD="bgcolor: #E2EFDA"]TL[/TD]
[TD="bgcolor: #E2EFDA"]
4​
[/TD]
[TD="bgcolor: #E2EFDA"]
4​
[/TD]
[TD="bgcolor: #E2EFDA"]
1​
[/TD]
[TD="bgcolor: #E2EFDA"]
1​
[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]167[/TD]
[TD]TL[/TD]
[TD]
1​
[/TD]
[TD]
0​
[/TD]
[TD]
2​
[/TD]
[TD]
2​
[/TD]
[/TR]
</tbody>[/TABLE]


Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"SiteCode", type text}}),
    #"Filled Up" = Table.FillUp(#"Changed Type",{"Q1", "Q2", "Q3", "Q4"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Up", each ([TeamLead] = "TL"))
in
    #"Filtered Rows"[/SIZE]

the assumption is that 99 means blank as you wrote in the first post
 
Upvote 0
Almost, there were some other assumptions -

Assumption 1 - that there were exactly two people on the team, TL and NL. I can adjust the data so that I take one NL, but what if there were no NL
Assumption 2 - What if the TL and the NL both code blank? Will Table.FillUp use the next non-empty cell? Even if it's from another site visit?
 
Upvote 0
post a link to representative source data in example excel file, with expected result
 
Last edited:
Upvote 0
I can work around assumption 1, it's just the issue of two blank in a row. Now, I code them as 99 but in order to use Table.FillUp, the cells have to be blank/empty, correct?

The expected result for both being blank would be just a 99.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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