Forum Discussion
Content from a previous row
Hi,
I want to make new column in which I want to put the content of an existing colomn "A" or the content from the previous row of the new colom depending on the content of column "A".
In Excel I can use this formula: IF(left(A2;1)="-";C1;B2)
I've tried several options (even chat GPT) but it won't work.
Kind regards,
Domien
watch my video and you will find out how to do this
7 Replies
- AhmedxSuper User
watch my video and you will find out how to do this
- DomienRegular Visitor
Thanks!. This works perfect for me!!
- 123abcCommunity Champion
In Power Query, you can create a new column that depends on the content of an existing column "A" or the content from the previous row of the new column based on the content of column "A." You can achieve this using the following steps:
Open Power Query Editor in Power BI or Excel.
Select your table that contains column "A."
Go to the "Add Column" tab and click on "Custom Column."
In the "Custom Column" dialog box, enter a name for the new column (e.g., "NewColumn").
In the "Custom column formula" box, enter the following formula:
if Text.Start([A], 1) = "-" then [NewColumn]{[Index]-1} else [A]
This formula checks if the first character of column "A" is "-", and if it is, it retrieves the value from the previous row of the "NewColumn"; otherwise, it takes the value from column "A."
- Click the "OK" button to create the new column.
This will create a new column "NewColumn" that meets your specified conditions. If the first character of column "A" is "-", it will take the value from the previous row of "NewColumn"; otherwise, it will take the value from column "A."
- DomienRegular Visitor
Thanks, for the quick reply.
I've tried something simular but when I use your solution I get errors whent the first character is an "-"
I've used this formula. I've checked the column names so that could not be the problem