Forum Discussion
Concatenate Following Line with Previous One in PowerBi
- 1 year ago
Hi Sir
The Second solution works, whereas the first one needs a tweek, It concatenates two valid transactiions if on the same date when it should not. Refer to 21 Oct ( Still in Solution 1).
Solution 2 seems to work perfectly. Kudos, kudos.
Hi JaweedL ,
To concatenate the split lines in Power BI and achieve a proper description for each transaction, you can use Power Query to achieve this. Follow the steps below:
Load the Data into Power Query:
- In Power BI, go to the Home tab and select Transform Data to open Power Query Editor.
- Load your bank statement data.
Add an Index Column:
- Go to the Add Column tab.
- Click Index Column > From 1. This will help identify the rows that should be combined.
Identify and Fill Down the Dates:
- In the Date column, select the cells, go to the Transform tab, and choose Fill Down. This will fill down the dates for the rows where only the description is present.
Identify Concatenated Rows:
- Add a Conditional Column to identify if the rows contain a description split across two lines:
- Go to the Add Column tab and select Conditional Column.
- Name it IsSubLine and create a rule: If the Description column equals null, then set it as "Yes". Otherwise, set it as "No".
- Add a Conditional Column to identify if the rows contain a description split across two lines:
Fill Down the Descriptions:
- In the Description column, go to the Transform tab and select Fill Down. This will fill down the descriptions where they are split across multiple rows.
Merge the Descriptions:
- Create a Custom Column to concatenate the descriptions:
- Go to the Add Column tab and select Custom Column.
- Use the formula: if [IsSubLine] = "Yes" then null else Text.Combine(List.RemoveNulls({[Description], try #"Previous Row".[Description] otherwise null}), " ")
- This will merge the main description with its subsequent part.
- Create a Custom Column to concatenate the descriptions:
Filter Out SubLines:
Filter the rows where IsSubLine is "Yes" and remove them since their content has been concatenated with the previous row.
Remove the Helper Columns:
Remove the IsSubLine column and the Index column.
Close & Apply:
Click Close & Apply to load the transformed data back into Power BI.
This process should give you a properly formatted description in Power BI.
If I have resolved your question, please consider marking my post as a solution. Thank you!
Hi
Thank you very much. I am still learning PowerBi.
In Step 6 above,
[IsSubLine] = "Yes" then null else... It throws me an error on the null in red.
In Step 5, I did not see any "Yes" appearing.
can you guide me, please. The solution proposed seems a nice one. Many thanks.