Forum

create a VLOOKUP in...
 
Notifications
Clear all

create a VLOOKUP in power query with with two conditions

7 Posts
3 Users
0 Reactions
97 Views
(@thenewbee)
Posts: 26
Eminent Member
Topic starter
 

Hello all,

I´m looking for a solution, to use something similar like VLOOKUP in a power query with two conditions.

 

We have a list of items/products, that is produced in one country.

These products are now sold in multiple different countries from the production country.

Screenshot-2023-02-28-152836-2.png

Now I would like to check if the countries are maintained correctly. We see on the first item, that´s available in 4 countries, but the source is inactive. "China" is inactive as well, so we need to maintain "Germany" and "France".

The second item is everywhere "active", so no action needed.

On the third item we see the source active, but "Germany" is inactive, so it needs corrected.

 

So I tried a VLOOKUP (in German "Sverweis") to figure out the correct combination. As there are multiple items and multiple enties about the production location, I had to do a combination of both. Also that combination does not look really nice in the table. And in addition I would prefere to have it Power Query.

Screenshot-2023-02-28-153205-2.png

Has somebody an idea, where I can start from? 🙂Smile

 
Posted : 01/03/2023 10:52 am
Alan Sidman
(@alansidman)
Posts: 223
Member Moderator
 

I am a bit confused as to what you want the end result to look like.  Please mock up a solution so we have a better idea.

 
Posted : 01/03/2023 2:30 pm
(@thenewbee)
Posts: 26
Eminent Member
Topic starter
 

Hello Alan,rnwell, I have a list, with muliple items, and these items are sold in multiple countries.rn(coulum F & coulmn I)rnAll of these items are sourced from one country (source of thruth) (column H)rn rnNow we have in that source of truth an item status, like active, or inactive and all othere items have to follow this.rn rnI would now like to see, which item has in all countries the same status as in the source of truth.rnrn rnSo in this example, the item A100 is procuded in USA. That region is inactive, so all other countries need to be on inactive as well.rnChina is already inactive, thats good, no action required. Germany and France are active, and habe to turn to inactive.rn 

 
Posted : 02/03/2023 12:28 pm
(@questvba)
Posts: 125
Estimable Member
 

Hi thenewbee,

From what I understand, this is what I propose.

1. You load your data in PwQ (t_source).
2. You duplicate this array and name it t_transfo. This will be the final result.
3. With t_source, you filter by 'produced in' and 'sold in' to get only 'USA'. You will have the unique status.
4. With t_transfo, you merge this table with the t_source table, keeping only the status column.

I did all this in the 'Source&Transfo' sheet.

 

BR, 

Lionel

 
Posted : 03/03/2023 1:46 am
(@thenewbee)
Posts: 26
Eminent Member
Topic starter
 

Hi all,

I´m sorry, that my previous post has no structure. There went something wrong by submitting them. 🙁

 

@ Lionel,

many thanks for this, it has a good starting point 🙂

In this case the results are correct.

The challange is, that you filtered only 'sold in' to get only 'USA'. You did this, as your understanding from column 'produced in' was always USA. I´m looking for that link.

If we change the production location for item "A100" in Germany and France, to Germany, they should follow that status.

So "A100" is produces in Europe in Germany. As Germany is active, France should be active as well.

For China and USA the production location will USA. As USA is now inactive, China should inactive as well.

 

Screenshot-2023-03-02-135227.png

 
Posted : 03/03/2023 8:50 am
(@questvba)
Posts: 125
Estimable Member
 

Hi thenewbee,

Here is the correction according to my understanding. 😉

BR,

Lionel

 
Posted : 03/03/2023 10:24 am
(@thenewbee)
Posts: 26
Eminent Member
Topic starter
 

Bonjour Lionel,

many thanks for this, that´s looks great 🙂

 
Posted : 07/03/2023 10:22 am
Share: