Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
10 years ago
Solved

Alternative to MAX

is there any function which gives us max of values in terms of strings? not integer 0's and true or false it should return the column value.
  • OwenAuger's avatar
    OwenAuger
    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.