Forum Discussion

COU_Alan's avatar
COU_Alan
Frequent Visitor
1 year ago
Solved

get latest text value by columns

hi all i'd like to get latest text value by columns   belows are sample datas and result what i want There are comment based on date, time, part, project name. i want to get latest comment...
  • OwenAuger's avatar
    1 year ago

    Hi COU_Alan 

    Here's one suggested measure.

    This handles multiple comments at the latest date/time by concatenating them, and excludes blank comments, but you can adjust this logic if needed.

    PBIX attached.

    Latest Comment = 
    VAR LatestDateTime =
        CALCULATETABLE (
            TOPN ( 1, SUMMARIZE ( Data, Data[date], Data[time] ), Data[date] + Data[time], DESC ),
            KEEPFILTERS ( NOT ISBLANK ( Data[comment] ) ) -- exclude blank comments
        )
    -- Concatenate comments if there are multiple at latest date/time
    VAR Comments =
        CALCULATE (
            CONCATENATEX (
                Data,
                Data[comment],
                "|"
            ),
            LatestDateTime
        )
    RETURN
        Comments