Forum Discussion
Custom Column
- 1 year ago
Hi bpierceaxo ,
The error occurs because the LEFT function is used in Excel and DAX, but not in the Power Query M language. The correct Power Query function to extract the first characters from a text string is Text.Start.
You can fix the issue by updating your formula to use the correct function. The new formula will get the first three characters from your [code] column and place them in your new Dept column.
= Table.AddColumn(#"Sorted Rows", "Dept", each Text.Start(Text.From([code]), 3))
In this corrected formula, Text.Start replaces LEFT. It's also a good practice to wrap your column name in Text.From(), as shown. This step ensures Power Query treats the column's data as text, which prevents errors if the original column has a number format.
Best regards,
Hi bpierceaxo ,
The error occurs because the LEFT function is used in Excel and DAX, but not in the Power Query M language. The correct Power Query function to extract the first characters from a text string is Text.Start.
You can fix the issue by updating your formula to use the correct function. The new formula will get the first three characters from your [code] column and place them in your new Dept column.
= Table.AddColumn(#"Sorted Rows", "Dept", each Text.Start(Text.From([code]), 3))
In this corrected formula, Text.Start replaces LEFT. It's also a good practice to wrap your column name in Text.From(), as shown. This step ensures Power Query treats the column's data as text, which prevents errors if the original column has a number format.
Best regards,