Hów to create a loop in Power BI, using Power query?

camillanaep

New Member
Joined
Nov 13, 2017
Messages
1
Hello everyone!

I have a query here wich contains 10 different columns. I need to create 4 other columns (A B C D), with formulas that contains values from this 10 first columns.
One of my inicial columns is called "Period", and it starts in 1. So, when period is equal 1, colunm A is equal another colunm in the query. Based on A value, it calculates values B, C and D.
When period is not 1, value D from the period before becomes value A, and using this A value, it calculates values B, C and D.



My query:


(Column 1) (Column 2) ..... (Wheight) (Period) (A) (B) (C) (D)

Basically it works like this:


  • My column (Wheight) contains always the same value (all rows have the same value).
  • The column "Period" starts in 1, and can end in 15 or 20.
  • Column "A" : when period=1, "A" = "wheight", and in the following rows, "A" = "D" from the period before.
  • "B", "C" and "D" are calculated based on the "A" value, with some formulas.
  • And "D" is calculated as a sum of "A", "B" and "C". (So, D value is always increasing, because is the A value plus other calculated values, in B and C.)

So whats happens is:
(an example)


(Column 1) (Column 2) ..... (Wheight) (Period) (A) (B) (C) (D)

100 1 100 0,02 4 104
100 2 104 0,06 3,5 107,5

....

The termination condition is when the next period is a number lower that the number before.



Does anyone know how can i do this?
I tried to create a power query formula, but i can't seem to get it right.

Thank you so much!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,214,832
Messages
6,121,847
Members
449,051
Latest member
excelquestion515

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