Forum Discussion
Alternative to MAX
- 10 years ago
Anonymous
You can use LASTNONBLANK to return the 'maximum' of a text column.
See this article on SQLBI:
https://www.sqlbi.com/articles/alternative-use-of-firstnonblank-and-lastnonblank/
- 9 years ago
Hi Anonymous,
That's right, LASTNONBLANK/FIRSTNONBLANK order text lexicographically.
If you want the text value with greatest length, you can do this or something similar:
Longest Text Value = CALCULATE ( LASTNONBLANK ( MyTable[TextColumn], 0 ), TOPN ( 1, VALUES ( MyTable[TextColumn] ), LEN ( MyTable[TextColumn] ) ) )If there are ties, they are broken by LASTNONBLANK.
Anonymous
You can use LASTNONBLANK to return the 'maximum' of a text column.
See this article on SQLBI:
https://www.sqlbi.com/articles/alternative-use-of-firstnonblank-and-lastnonblank/
- Anonymous10 years agoNot applicable
Hi OwenAuger,
Actually i found this blog after a little search.
Anyway thank you so much for your reply.
- Anonymous9 years agoNot applicable
Hi OwenAuger,
The LastNonBlank and FirstNonBlank fuctions giving me the first and last nonblank strings but i need values with maximum character length in the column.!!
- OwenAuger9 years agoSuper User
Hi Anonymous,
That's right, LASTNONBLANK/FIRSTNONBLANK order text lexicographically.
If you want the text value with greatest length, you can do this or something similar:
Longest Text Value = CALCULATE ( LASTNONBLANK ( MyTable[TextColumn], 0 ), TOPN ( 1, VALUES ( MyTable[TextColumn] ), LEN ( MyTable[TextColumn] ) ) )If there are ties, they are broken by LASTNONBLANK.