The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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