Forum Discussion
Jthathaisa
7 years agoRegular Visitor
Adding a loop in Power Bi
Hi Team, How does one add this loop below in power BI let start = 100; const rows = []; for (let i = 0; i < rows.length; i++) { start = start * (rows[i].priceChange + 1); } The aim o...
Anonymous
7 years agoNot applicable
Could you please post sample data and desired outcome?
Jthathaisa
7 years agoRegular Visitor
Sample Data:
Price change | Formula | Desired outcome |
0.00 | 100 * (Price Change +1) | 100 |
-0.02 | 100 * (Price Change +1) | 98 |
-0.05 | 100 * (Price Change +1) | 95 |
0.00 | 95* (Price Change +1) | 95 |
0.01 | 95* (Price Change +1) | 95.95 |
0.00 | 95.95* (Price Change +1) | 95.95 |
-0.02 | 95.95* (Price Change +1) | 94.031 |
so my starting formula is 100 *(price change +1), and continues until my price change = 0.00, if my price change = 0.00 then take the pervious desired outcome and substitue the 100 with the desired outcome i.e 95* (Price Change +1)
I believe my loop is as follows :
let start = 100;
let price=0;
const rows = [];
for (let i = 0; i < rows.length; i++) {
start = rows[i].priceChange === 0.00 ? desiredoutcome : start;
price = start * (rows[i].priceChange + 1);
}