Equivalent of Text to Columns in Power Query

borkybork

New Member
Joined
Aug 5, 2022
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hi! I created a column in power query with a mix of numbers, letters and symbols (ie. “1234567”, “A123456” or “A-1234567”). The current data type in PQ is “Int.64”. The problem is my Xlookup in excel is returning zero values. The formula works when I change the type to Number (in PQ) but the ones with letters and symbols give me an error (in PQ), and then hides them in excel. My workaround is to select the column then go to Data>Text to Columns in order for my xlookup to work. But I’d have to do that every time I refresh the table. Is there a way to do it in power query and avoid the extra step? Thanks in advance!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I'm having a bit of an issue visualizing what you want to do. Please load some sample data using XL2BB and then show a mocked up solution for the items shown. 6-8 records is probably all we need to see in order to give you a viable PQ solution.
 
Upvote 0
I'm having a bit of an issue visualizing what you want to do. Please load some sample data using XL2BB and then show a mocked up solution for the items shown. 6-8 records is probably all we need to see in order to give you a viable PQ solution.
Thanks for responding and sorry for the late reply! I can't get the XL2BB to work atm, but I hope the screenshots can help visualize my data.
The goal is to get the amount paid from table 2 by doing an xlookup of the Invoice number from Table 1.

1699108976151.png


Table 1 is a PQ table and the problem is my xlookup is returning 0 values for Joe and Ringo. The data type in PQ is Int.64, but when you change it to a number, Joe's and Ringo's invoice #s are showing Error and are not in the output table. The best solution I found was to keep the Int.64 data type in PQ and then do Text To Columns on the Invoice Number, but then you have to do that each time you refresh the table. I have several worksheets so I'd like to be able to just refresh them without the extra step. Hope this helps clarify things!

1699107805906.png
 
Last edited:
Upvote 0
I put both tables into PQ and did the math there

Power Query:
let
    T1 = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    CT = Table.TransformColumnTypes(T1,{{"Invoice Number", type text}, {"Invoice Amount", Currency.Type}}),
    T2 = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    CT2 = Table.TransformColumnTypes(T2,{{"Invoice Number", type text}, {"Amount Paid", Currency.Type}}),
    MQ = Table.NestedJoin(CT, {"Invoice Number"},CT2, {"Invoice Number"}, "Tbl", JoinKind.LeftOuter),
    Expand= Table.ExpandTableColumn(MQ, "Tbl", {"Amount Paid"}, {"Amount Paid"}),
    Difference= Table.AddColumn(Expand, "Subtraction", each [Invoice Amount] - [Amount Paid], Currency.Type),
    RC = Table.RenameColumns(Difference,{{"Subtraction", "Balance Remaining"}})
in
    RC

Book3
ABCDEFGHIJKLM
1NameInvoice NumberInvoice AmountNameInvoice NumberAmount PaidNameInvoice NumberInvoice AmountAmount PaidBalance Remaining
2Jane Smith1234567100000Jane Smith123456720000Jane Smith12345671000002000080000
3Joe SchmoeA-1234567200000Joe SchmoeA-123456730000Joe SchmoeA-123456720000030000170000
4Ringo StarrAC12345678300000Ringo StarrAC1234567840000Ringo StarrAC1234567830000040000260000
Sheet1
 
Upvote 1
Solution
I put both tables into PQ and did the math there

Power Query:
let
    T1 = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    CT = Table.TransformColumnTypes(T1,{{"Invoice Number", type text}, {"Invoice Amount", Currency.Type}}),
    T2 = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    CT2 = Table.TransformColumnTypes(T2,{{"Invoice Number", type text}, {"Amount Paid", Currency.Type}}),
    MQ = Table.NestedJoin(CT, {"Invoice Number"},CT2, {"Invoice Number"}, "Tbl", JoinKind.LeftOuter),
    Expand= Table.ExpandTableColumn(MQ, "Tbl", {"Amount Paid"}, {"Amount Paid"}),
    Difference= Table.AddColumn(Expand, "Subtraction", each [Invoice Amount] - [Amount Paid], Currency.Type),
    RC = Table.RenameColumns(Difference,{{"Subtraction", "Balance Remaining"}})
in
    RC

Book3
ABCDEFGHIJKLM
1NameInvoice NumberInvoice AmountNameInvoice NumberAmount PaidNameInvoice NumberInvoice AmountAmount PaidBalance Remaining
2Jane Smith1234567100000Jane Smith123456720000Jane Smith12345671000002000080000
3Joe SchmoeA-1234567200000Joe SchmoeA-123456730000Joe SchmoeA-123456720000030000170000
4Ringo StarrAC12345678300000Ringo StarrAC1234567840000Ringo StarrAC1234567830000040000260000
Sheet1
this is perfect, thank you so much!
 
Upvote 0

Forum statistics

Threads
1,216,500
Messages
6,131,016
Members
449,615
Latest member
Nic0la

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