Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
I have a complex Power Query formula which determines my columns based on the week number we are in.
It basically looks at the week I am in and gets the columns for 2 weeks before the current week and 5 weeks after the current week.
So today it will bring back Columns 3, 4, 5, 6, 7, 8, 9 and 10 Next week it will bring back 4, 5, 6, 7, 8, 9, 10 and 11
I am now trying to write a formula that add a certain amount on to each column
Written normally the formula would be
(([4]/2)*10)
but that [4] will change to [5] next week and so on.
How do I write something that can change the column based on the week I am in?
You can do this something like:
= Table.TransformRows(PreviousStep, each _ & Record.TransformFields(_, List.Zip({List.Range(Record.FieldNames(_), <start index>, <end index or null for the end>), each _ / 2 * 10})))
That is:
For each row, modify it with (Table.TransformRows):
Hi @SiGill1979 ,
Do you want to select dynamic columns from source table or calculate a result from dynamic columns?
sorry, Im not getting what do you exactly want and how do you see desired output, but i already hae a question. why dont you just multiply to 5? like [4]*5, why ([4]/2)*10 ?
do not hesitate to give a kudo to useful posts and mark solutions as solution
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 18 | |
| 13 | |
| 9 | |
| 8 | |
| 8 |