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.

SiteCode
TeamLead
Q1
Q2
Q3
Q4
033
TL
1
2
3
5
033
NL
1
2
3
5
151
TL
99
2
4
4
151
NL
1
2
3
3
222
TL
4
99
1
1
222
NL
2
4
2
3
167
TL
99
0
99
99
167
NL
1
3
2
2

<tbody>
</tbody>


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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
try this

SiteCodeTeamLeadQ1Q2Q3Q4
033TL
1​
2​
3​
5​
151TL
1​
2​
4​
4​
222TL
4​
4​
1​
1​
167TL
1​
0​
2​
2​

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

[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]SiteCode[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]TeamLead[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Q1[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Q2[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Q3[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Q4[/COLOR]
033TL
1​
2​
3​
5​
151TL
1​
2​
4​
4​
222TL
4​
4​
1​
1​
167TL
1​
0​
2​
2​

<tbody>
</tbody>


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,214,788
Messages
6,121,597
Members
449,038
Latest member
Arbind kumar

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