Hi,
currently I'm looking how to manage something like 'truncate a text (<txt>) by 1 character of it's length', which in general is pretty easy with
Text.Start(<txt>, Text.Length(<txt>)-1)
But I want to make shure, that this will not generate an error in case the <txt> is empty. Therefore I'd like to write something like
Text.Start(<txt>, MAX(0,Text.Length(<txt>)-1))
Any idea? Thanks!
RaiSta
Hi RaiSta,
You could try
if Text.Length(<txt>) > 0 then Text.Start(<txt>, MAX(0,Text.Length(<txt>)-1)) else null
Regards
Phil
You could also do something like:
Text.Start(<txt>, List.Max({0,Text.Length(<txt>)-1})))
Just bear in mind that you are likely to end up with a mix of empty text and null values in the resulting column.
Thanks Philip, thanks Velouria,
both answers seem to fulfil my needs, but I can mark only one to be an ('the') answer... so I took the first.
Will see, as soon as I'm back to the topic of interest how it works in 'free nature' - but this could take some time. And I will not set it to 'null', but to the original text, because only 'truncatable' texts will be modified. This will be just a safety issue, to cover rare cases outside my test environments, that the query will not throw an error which might not be able to be handled from persons using my design. You know: it works well in all tested cases and 99.xxx% of all applications. But after long time of working all of a sudden an 'unexplainable' error shows up, me maybe no longer at hand or whatever else. Just to be prepared...
Thanks for your contributions,
RaiSta