SOLVED

Vlookup to find multiple variations of a text string

Copper Contributor

Hi, first time post here so bear with me!

 

I am trying to create a worksheet that displays a list of shift types with names of staff allocated that shift over the period of a week.

I can do this for straightforward shifts but occasionally we have to ask staff to double up on shifts and the vlookup formula I am using wont find the double shifts.

The problem is that there are too many possible combinations of double shifts for me to list them all on the worksheet so I need a formula that can find any possible combination and display the staff member who has been allocated it?

Sample File attached.

 

Thanks

28 Replies
best response confirmed by othafa (Copper Contributor)
Solution

@othafa 

With the help of PQ and the data model.

 

@Detlef Lewin 

Thanks for this, it certainly does what I want. 

 

Is there a way to convert sheet 1 into the table (A1:C24) you created in Tabelle1. I ask because the format of sheet1 is fixed as it is?

 

Thanks.

@othafa 

That is the PQ part. Goto to the PQ editor to see the queries and steps.

To load the table into PQ I assigned a name to the table range (-> name manager),

 

Wow, never heard of the PQ editor! Anyway found it and am looking at the steps you took and kind of understand how it works. Just need to apply it to my original sheet now! Once it's set up does it automatically change the pivot table if the source data changes? I'm asking because there was an error in the source data on sheet 1 and when I changed that the pivot table didn't reflect the change.
Thanks again!

@othafa 

You need to refresh.

First refresh the PQ table -> right click -> refresh.

Then refresh the pivot table -> right click -> refresh.

 

Ok that's fine, just one last issue I think!

I'm just getting a count of name in the pivot table, cant see how to actually convert that to the name of the staff?

@othafa 

I provided a link to an article from Mr Excel in the workbook. Just follow the steps.

 

Ok got it now thanks so much for all your help.
Vest wishes

@Detlef Lewin 

Hi, many apologies but I've hit a snag. When I was working on your fix for the problem I was using my home version of excel which is Microsoft Office 2016. Unfortunately the version at work is Office Standard  2010 and reading up on it online the Power Query is not available for this version, only the professional plus 2010.

 

What this means is that I don't get the option of adding the data to the data model when I create the pivot table.

 

Back to square one?

 


@othafa wrote:

Back to square one?


So it seems.

Or you could argue with your boss and your IT that with a more recent version of Excel you will be able to perform this specific task easily.

And besides Excel 2010 is almost 10 years old.

@othafa 

A formula solution.  The key element is to perform a wildcard search for anything that contains a shift name, e.g. search for "*LMP*".  There is a catch that the abbreviations for Early and Late are to be found within other shift codes so I converted them to "E0" and "L0" to avoid 'false positives'.

 

= IFERROR( INDEX( Name, MATCH( shift, INDEX(shiftTable, 0, day), 0 ) ), "" )

The names 'day' and 'shift' are relative references and the innermost INDEX returns the 3 rows for a given day of the table.

 

As for your other line of exploration, Power Query is available as an Office 2010 add-in free of charge from Microsoft.  Your IT department could install it for you and I would recommend that they evaluate it themselves!

 

@Peter Bartholomew , that's only for this 2010

image.png

 

@Sergei Baklan 

For me, what the documentation suggests and what actually happened were not the same thing.  Power Query and Power Pivot both installed despite my not having the correct version of Office.

 

Now I am using Office 365 insider but that is because I was desperate to evaluate modern Dynamic Arrays (they are superb and now provide the basis of everything I do outside Power Query).

@Peter Bartholomew 

Did you compare your solution with my solution?

Your missing some shifts: DO, LMP1.

And your missing multiple names for the same shift on the same day.

And LMP produces false positives because of LMP1 and LMP2.

 

@Detlef Lewin @Peter Bartholomew 

Peter's solution looks good, I'll need to run it in the real schedule obviously to test it.

 

Not concerned if it doesnt pick up DO as those are days off which we don't need to display on sheet 2 (in Peter's solution I was intending to deselect DO and AL in the filter section of the pivot table using a macro) but would be concerned if it doesnt pick up duplicates at all.

 

My bad, the LMP should be LMP1 but we only use a number in shift codes if there are two people doing the same shift. In other words there is a CWE but will never be a CWE1 or CWE2. I think Ive just resolved the duplicate issue....the only duplicates we do use are the E and L shifts and we could possibly number them so no need to call them EO and LO.

 

Ill try the download myself but company admin privaledges may prevent me doing that, if so and I get someone in IT to look at it for me they may just come back and tell me it wont work!

 

Watch this space and thanks again for the help.

Hi, I've now converted the original file to use the formula you gave me but it's not working properly. I'm on a steep learning curve here as I've never worked with arrays before and hardly ever with Index and Match.

Anyway I set up the named ranges for the constants adjusted for the real data and set it going. It correctly gives me the names for the shifts on Monday but just repeats that name for the rest of the week.

I've run the Evaluate Formula feature and as it steps through it everything seems to be going right until the last step when it reverts to the name it gave for Monday.

Any thoughts?

 


@Peter Bartholomew wrote:

@Sergei Baklan 

For me, what the documentation suggests and what actually happened were not the same thing.  Power Query and Power Pivot both installed despite my not having the correct version of Office.

 

Now I am using Office 365 insider but that is because I was desperate to evaluate modern Dynamic Arrays (they are superb and now provide the basis of everything I do outside Power Query).


Hi Peter,

Yes, I agree with both.

Documentation could be outdated. That was with "Where is Power Pivot" when expanding of Power Pivot on all SKU was announced first on uservoice, and doc was updated only in a while. Sometimes delay could be quite significant. However, I don't think there were some changes for outdated 2010.

 

Power Query becomes less important if you work within one notebook. My main scenarios of usage is to pick-up and transform data from different sources (SQL databases, files on SPO and like) to combine in one workbook with its local data. That was I did with Pivot Table connectors long ago, now PQ is the main tool.

 

@Peter Bartholomew 

@othafa 

The catch might be that 'day' is a relative reference to the indices 1,...7 above the table.  To get a fresh value for each column, the array formula is applied to a single column and then copied across to give a set of 7 array formulas rather than one single array formula.

Not sure I follow but cant understand why you fix on my example works but it wont work on the real data.

Was wondering if there is an issue with shifts in the source data that don't appear in the left hand column of sheet2?

There are about 50 core shifts and while these might appear in the source data I haven't yet been able to ensure that they all appear in the shift column on sheet 2.
1 best response

Accepted Solutions
best response confirmed by othafa (Copper Contributor)
Solution

@othafa 

With the help of PQ and the data model.

 

View solution in original post