Power Query: Column and Row Lookup

Pulsar3000

New Member
Joined
Apr 19, 2021
Messages
44
Office Version
  1. 365
Platform
  1. Windows
Hello All:

Hope you can all help with my task at hand.
I want to multiply the percentage from the "Criteria" tab that matches the dollar amount for the respective Location, Customer Risk, and Days Old in the "Data" tab.
For example, the corresponding percentage from the "Criteria" tab for cell D3 in the "Data" tab is 2%.
I then want to take this 2% and multiply it by the amount in cell D3 which has $30,000.

I know merge queries in Power Query allows for matching columns and in my case this would work for the Location and Risk column.
However, how do I do the three-way match in Power Query when the the "days old" item is in a row?

PQ Row Lookup.xlsx
ABCDEFG
1LocationCustomerCustomer Risk0 - 30 Days31 - 60 Days61 - 90 Days90+ Days Old
2NorthAdamLow$20,000$15,000$10,000$5,000
3NorthJohnHigh$30,000$25,000$20,000$15,000
4NorthDavidMedium$40,000$35,000$30,000$25,000
5NorthAndrewLow$50,000$45,000$40,000$35,000
6SouthSeanLow$60,000$55,000$50,000$45,000
7SouthJosephHigh$70,000$65,000$60,000$55,000
8SouthIshmaelMedium$80,000$75,000$70,000$65,000
9SouthParkerLow$90,000$85,000$80,000$75,000
Data

PQ Row Lookup.xlsx
ABCDEF
1LocationRisk0 - 30 Days31 - 60 Days61 - 90 Days90+ Days Old
2NorthLow0.50%0.75%1.00%1.25%
3NorthMedium1.00%1.50%2.00%2.50%
4NorthHigh2.00%2.50%3.00%3.50%
5SouthLow0.70%0.95%1.20%1.45%
6SouthMedium1.20%1.70%2.20%2.70%
7SouthHigh2.20%2.70%3.20%3.70%
Criteria
 
The solution in Power Query is to convert the data in rows into columns by unpivoting and then pivoting back.
So basically we can't do a row lookup in Power Query?

You can but then you have the issue of having to multiply each column individually eg Customer 0-30 x PerCent 0-30, Customer 31-60 x PerCent 31-60.
Doing it that way would also mean you will have hardcoded the aging columns, the way it is currently, if you change the aging grouping it would still work.

I have only used the User Interface to build it, if you are prepared to do more using M, then I am sure there will other ways of doing it
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,214,523
Messages
6,120,028
Members
448,940
Latest member
mdusw

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