JugglerJAF
Active Member
- Joined
- Feb 17, 2002
- Messages
- 297
- Office Version
- 365
- Platform
- Windows
I have a data table that looks something like this (fake data obviously) that's been pulled from a text file and brought into Excel using the Power Query AddIn for Excel 2013.
[TABLE="class: grid, width: 276"]
<tbody>[TR]
[TD]Direction[/TD]
[TD]Email[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]adam.zapple@xyz.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]pepper.mintz@abcd.com[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]ella.vator@lmnop.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]gerry.actrick@abcd.com[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]adam.zapple@12345.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]mel.tingpoint@abcd.com[/TD]
[/TR]
</tbody>[/TABLE]
What I want to do is to create a calculated field within the Power Query environment that would look at each row and return the following (logic used to get to this is explained after the table)
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="width: 90"]Direction[/TD]
[TD="width: 186"]Email[/TD]
[TD="width: 175"]FROM[/TD]
[TD="width: 169"]TO[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]adam.zapple@xyz.com[/TD]
[TD]adam.zapple@xyz.com[/TD]
[TD]pepper.mintz@abcd.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]pepper.mintz@abcd.com[/TD]
[TD]ignore[/TD]
[TD]ignore[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]ella.vator@lmnop.com[/TD]
[TD]ella.vator@lmnop.com[/TD]
[TD]gerry.actrick@abcd.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]gerry.actrick@abcd.com[/TD]
[TD]ignore[/TD]
[TD]ignore[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]adam.zapple@12345.com[/TD]
[TD]adam.zapple@12345.com[/TD]
[TD]mel.tingpoint@abcd.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]mel.tingpoint@abcd.com[/TD]
[TD]ignore[/TD]
[TD]ignore[/TD]
[/TR]
</tbody>[/TABLE]
So, for each row, if the direction is "Outbound" and the direction on the next row is "Inbound", then populate the "FROM" column with the email address from the row and also populate the "TO" column with the email address from the next row. If both criteria are not met, then populate both columns with "ignore".
It's easy enough to do this with a formula in Excel once the data has been brought through by Power Query, but I'd like to do it within the Power Query environment, so that I can then apply an additional filter to the data within the query to filter out any records in the "FROM" column that are equal to "ignore" which will reduce by half the amount of data that's being populated into Excel.
I've tried Googling for a solution, but everything I find includes the instruction "In the Query Editor ribbon, click Insert Custom Column.", but I don't seem to have that option on my ribbon menu.
[TABLE="class: grid, width: 276"]
<tbody>[TR]
[TD]Direction[/TD]
[TD]Email[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]adam.zapple@xyz.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]pepper.mintz@abcd.com[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]ella.vator@lmnop.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]gerry.actrick@abcd.com[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]adam.zapple@12345.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]mel.tingpoint@abcd.com[/TD]
[/TR]
</tbody>[/TABLE]
What I want to do is to create a calculated field within the Power Query environment that would look at each row and return the following (logic used to get to this is explained after the table)
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="width: 90"]Direction[/TD]
[TD="width: 186"]Email[/TD]
[TD="width: 175"]FROM[/TD]
[TD="width: 169"]TO[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]adam.zapple@xyz.com[/TD]
[TD]adam.zapple@xyz.com[/TD]
[TD]pepper.mintz@abcd.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]pepper.mintz@abcd.com[/TD]
[TD]ignore[/TD]
[TD]ignore[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]ella.vator@lmnop.com[/TD]
[TD]ella.vator@lmnop.com[/TD]
[TD]gerry.actrick@abcd.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]gerry.actrick@abcd.com[/TD]
[TD]ignore[/TD]
[TD]ignore[/TD]
[/TR]
[TR]
[TD]Outbound[/TD]
[TD]adam.zapple@12345.com[/TD]
[TD]adam.zapple@12345.com[/TD]
[TD]mel.tingpoint@abcd.com[/TD]
[/TR]
[TR]
[TD]Inbound[/TD]
[TD]mel.tingpoint@abcd.com[/TD]
[TD]ignore[/TD]
[TD]ignore[/TD]
[/TR]
</tbody>[/TABLE]
So, for each row, if the direction is "Outbound" and the direction on the next row is "Inbound", then populate the "FROM" column with the email address from the row and also populate the "TO" column with the email address from the next row. If both criteria are not met, then populate both columns with "ignore".
It's easy enough to do this with a formula in Excel once the data has been brought through by Power Query, but I'd like to do it within the Power Query environment, so that I can then apply an additional filter to the data within the query to filter out any records in the "FROM" column that are equal to "ignore" which will reduce by half the amount of data that's being populated into Excel.
I've tried Googling for a solution, but everything I find includes the instruction "In the Query Editor ribbon, click Insert Custom Column.", but I don't seem to have that option on my ribbon menu.
Last edited: