Can relative column references be used in Power Query custom columns?

Joe_S

New Member
Joined
Feb 22, 2012
Messages
6
I receive data for a list of balances from year 2020 to year 2050. The data is in the format of the first table below. For each year of data, I am adding 3 additional calculated custom columns in PQ as shown in the second table. The formulas are the same for all years. The custom column formulas for the first year are working, but it will be a tedious and time consuming undertaking to replicate them for the other 30 years. I was wondering if there are relative column references that I could use so the same formula can be used for all years without writing a custom column function for each column and explicitly referencing the columns.

My data source looks like this

NameYear 2020Year 2021Year 2022
Item 11014-18
Item 2-121620


It looks like this after adding the 3 calculated columns, but they need to be added for all years.

NameYear 20202020 (Calc 1)2020 (Calc 2)2020 (Calc 3)
Item 110If[Year 2020}<0 then 1 else 2 if 2020 calc1 > 2 then year 2020balance else 2020 calc3if 2020 calc 2 > year 2020 balance then 1 else 2
Item 2-12
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
unp.png

maybe try now add your three columns (with or without attribute condition)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,794
Messages
6,174,643
Members
452,575
Latest member
Fstick546

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