The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi Dears,
I need to display around the first 600 characters of a long text field but the left function truncate the word sometimes.
How can I get left part of a long text but get the last full word after a certain position.
Best regards,
Augusto
Solved! Go to Solution.
hi @Anonymous
you can try something like this
someColumn =
VAR _currentString =
CALCULATE ( SELECTEDVALUE ( 'Table1'[Column1] ) )
VAR _rightPartOfString =
RIGHT ( _currentString; LEN ( _currentString ) - 600 )
VAR _firstSpace =
SEARCH ( " "; _rightPartOfString ) - 1
RETURN
LEFT ( _currentString; 600 + _firstSpace )
This code expands the left function to the first space after character number 600.
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
hi @Anonymous
you can try something like this
someColumn =
VAR _currentString =
CALCULATE ( SELECTEDVALUE ( 'Table1'[Column1] ) )
VAR _rightPartOfString =
RIGHT ( _currentString; LEN ( _currentString ) - 600 )
VAR _firstSpace =
SEARCH ( " "; _rightPartOfString ) - 1
RETURN
LEFT ( _currentString; 600 + _firstSpace )
This code expands the left function to the first space after character number 600.
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Hi Surla,
I'm facing a challange yet. When the long text has less than 600 characters.
Could you please help me!
Thanks,
Augusto
someColumn =
VAR _currentString =
CALCULATE ( SELECTEDVALUE ( 'Table1'[Column1] ) )
VAR _rightPartOfString =
RIGHT ( _currentString; LEN ( _currentString ) - 600 )
VAR _firstSpace =
SEARCH ( " "; _rightPartOfString ) - 1
RETURN
IF (
LEN ( _currentstring ) <= 600;
_currentstring;
LEFT ( _currentString; 600 + _firstSpace )
)
Hi Dear Sturla,
Last night I tried the same approach as you posted above and got trhe same error message.
"An argument of function 'RIGHT' has the wrong data type or has an invalid value."
Thanks for your attention,
Augusto
try this
someColumn =
VAR _currentString =
CALCULATE ( SELECTEDVALUE ( 'Table1'[Column1] ) )
VAR _rightPartOfString =
IF (
LEN ( _curentstring ) <= 600;
BLANK ();
RIGHT ( _currentString; LEN ( _currentString ) - 600 )
)
VAR _firstSpace =
IF ( ISBLANK ( _rightPartOfString ); 0; SEARCH ( " "; _rightPartOfString ) - 1 )
RETURN
IF (
LEN ( _currentstring ) <= 600;
_currentstring;
LEFT ( _currentString; 600 + _firstSpace )
)
Hi Dear Sturla,
You save me a lot of effort to get to a measure likes you provided.
Your solution works perfectly.
Thanks a lot.
Augusto
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
102 | |
82 | |
62 | |
56 |
User | Count |
---|---|
254 | |
119 | |
115 | |
99 | |
71 |