Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I feel like Power BI is automatically trimming my data. Is there a way to not have that happen?
I am importing txt files with | as the delimeter. Lets say "21B", "21B " and " 21B" are the data values for one of the fields, Power BI will automatically see them as "21B" without the leading and trailing spaces which is not what I want. I need to detect the spaces in my work process.
I don't see any options to have this undone (transform -> format, only has trim which its already doing for unknown reason), and I haven't applied any steps to trim it. I also don't see any helpful option in the data source setting.
Please assist.
My experience is as-per this article
powerbi engine removes trailing spaces but not leading spaces. This is not Power Query (which leaves them in).
This is what i have in the 'transform data' section, as you can see i did not trim anything.
Here is my txt file:
As you can see there are about 16 cases where there are spaces in them, thus the length is >3.
but with this code: "RouteIDError = IF(NOT(LEN('Duplicate'[Route ID]) = 3), "Route ID ", "")", I only get 5 RouteIDError, it does not count the trailing spaces.
How do I have powerbi include the leading and trailing spaces? Please assist.
That is not your M code. Open the advanced editor, found in the view menu and copy paste.
The problem may be in the change type step. If it changes to numeric, it will definitely remove spaces....
This is what i have
Can you share your M code? All steps from loading the file to where your query fails?
This is what i have in the 'transform data' section, as you can see i did not trim anything.
Here is my txt file:
As you can see there are about 16 cases where there are spaces in them, thus the length is >3.
but with this code: "RouteIDError = IF(NOT(LEN('Duplicate'[Route ID]) = 3), "Route ID ", "")", I only get 5 RouteIDError, it does not count the trailing spaces.
How do I have powerbi include the leading and trailing spaces? Please assist.
"I feel like Power BI is automatically trimming my data" - Where are you seeing that happening? Can you show us please?
So I have this "RouteIDError = IF(NOT(LEN('Duplicate'[Route ID]) = 3), "Route ID ", "")", which checks that Route ID (text format), and if it is not a len of 3, it would return "Route ID ", otherwise blank. But it does not count leading and trailing spaces. Such that " 21B" and "21B ", should be counted as a len of 4 including the space but it does not. But if there is a space in between the text, like "21 B" or "2 1B", it would count it as len of 4. So it does automatically trims it and ignores the leading and trailing spaces. So I'd assume it's an issue with the data source settings, but I can't find any option that deals with this.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
10 | |
7 | |
7 | |
6 | |
6 |