Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hi experts!
I have a column with text and numbers.
Now I would like to remove the last 2 characters, if it is a number.
From "1A" to "A".
But how with dax?
Solved! Go to Solution.
In Power BI, you can achieve this using DAX (Data Analysis Expressions). You can create a new calculated column or measure depending on your requirement. Here's how you can do it using a calculated column:
Now, you can use the following DAX expression to create a new column:
NewColumn =
IF(
ISNUMBER(VALUE(LEFT(YourTableName[YourColumnName], LEN(YourTableName[YourColumnName])-2))),
LEFT(YourTableName[YourColumnName], LEN(YourTableName[YourColumnName])-2),
YourTableName[YourColumnName]
)
Replace YourTableName with the name of your table and YourColumnName with the name of the column containing the text and numbers.
This DAX expression does the following:
After you've entered the DAX expression, press Enter. It will create a new column in your table with the desired result.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Hi @joshua1990
You can use M function in Power Query.
Here is my trying.
My sample:
1. Split Column by Position
2. add a Custom Column
Text.Select([Value.2], {"a".."z", "A".."Z"})
3. Select the two columns that need to be merged
4. remove Value.2 Column
5. Result
Here is the whole M function in Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WioiIdAmOUorViVYK9vYwNgGzHH28vQwdwUw/72AfIzDL0MjYxM0FwjQ2NDIxhgibGJtCBI1NTN2BQrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", type text}}),
#"Split Column by Position" = Table.SplitColumn(#"Changed Type", "Value", Splitter.SplitTextByPositions({0, 2}, true), {"Value.1", "Value.2"}),
#"Added Custom" = Table.AddColumn(#"Split Column by Position", "Custom", each Text.Select([Value.2], {"a".."z", "A".."Z"})),
#"Merged Columns" = Table.CombineColumns(#"Added Custom",{"Value.1", "Custom"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
#"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Value.2"})
in
#"Removed Columns"
Best Regards,
Yulia Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
If you don't wan to make changes in M like @Anonymous suggested or use a column. Here is a measure:
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
Proud to be a Super User!
Hi,
If you don't wan to make changes in M like @Anonymous suggested or use a column. Here is a measure:
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
Proud to be a Super User!
Hi @joshua1990
You can use M function in Power Query.
Here is my trying.
My sample:
1. Split Column by Position
2. add a Custom Column
Text.Select([Value.2], {"a".."z", "A".."Z"})
3. Select the two columns that need to be merged
4. remove Value.2 Column
5. Result
Here is the whole M function in Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WioiIdAmOUorViVYK9vYwNgGzHH28vQwdwUw/72AfIzDL0MjYxM0FwjQ2NDIxhgibGJtCBI1NTN2BQrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", type text}}),
#"Split Column by Position" = Table.SplitColumn(#"Changed Type", "Value", Splitter.SplitTextByPositions({0, 2}, true), {"Value.1", "Value.2"}),
#"Added Custom" = Table.AddColumn(#"Split Column by Position", "Custom", each Text.Select([Value.2], {"a".."z", "A".."Z"})),
#"Merged Columns" = Table.CombineColumns(#"Added Custom",{"Value.1", "Custom"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
#"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Value.2"})
in
#"Removed Columns"
Best Regards,
Yulia Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
In Power BI, you can achieve this using DAX (Data Analysis Expressions). You can create a new calculated column or measure depending on your requirement. Here's how you can do it using a calculated column:
Now, you can use the following DAX expression to create a new column:
NewColumn =
IF(
ISNUMBER(VALUE(LEFT(YourTableName[YourColumnName], LEN(YourTableName[YourColumnName])-2))),
LEFT(YourTableName[YourColumnName], LEN(YourTableName[YourColumnName])-2),
YourTableName[YourColumnName]
)
Replace YourTableName with the name of your table and YourColumnName with the name of the column containing the text and numbers.
This DAX expression does the following:
After you've entered the DAX expression, press Enter. It will create a new column in your table with the desired result.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 8 | |
| 8 | |
| 7 |