Add column from matching value in another row - Query Editor

horseyride

Board Regular
Joined
Nov 2, 2017
Messages
82
This should be very simple, but I'm stumped.
I want to add a column by matching the current value of [Last Year-Week] and pulling in the associated [Sales] value


Year-Week
Last-Year-Week
Sales
2017-012016-01100
2017-022016-02200
2017-032016-03300
2017-042016-04400
2018-012017-01500
2018-02
2017-02600
2018-03
2017-03700
2018-042017-04800

<tbody>
</tbody>

to:

Year-WeekLast-Year-Week
SalesPrevious Sales
2017-012016-01100null
2017-022016-02200null
2017-032016-03300null
2017-042016-04400null
2018-012017-01500100
2018-022017-02600200
2018-032017-03700300
2018-042017-04800400

<tbody>
</tbody>

= Table.AddColumn(Source, "Previous Sales", each if [#"Year-Week"] = [Last Year-Week] then [Sales] else 0 )
No idea why this doesn't work
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Duplicate your query and then merge them together using the Year-Week from one query and Last-Year-Week from the other.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,603
Members
449,089
Latest member
Motoracer88

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