Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
COU_Alan
Frequent Visitor

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

COU_Alan_0-1740099524043.png

There are comment based on date, time, part, project name.

i want to get latest comment based on date, time, part, project name.

 

for example part b has 2 comments in project 1

but 'i solved ptrouble' is latest comment, so  part b's project 1 comment is 'i solved ptrouble'

 

i tried several times but failed.

i need help

 

thanks 🙂

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

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

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

5 REPLIES 5
OwenAuger
Super User
Super User

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

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Hi @OwenAuger 
can you help one more thing??

COU_Alan_0-1740112786865.png

my final goal is add working hour by day(or week whatever) like upper table in image

but using your dax result is like below
(I'm not saying that the dax you gave me is wrong, just that it's telling me what's going on.)

 

can you help me one more to get result what i want??

 

Hi @COU_Alan,

Sure, I can give some suggestions for that. We should set up the model a bit more carefully with Date/Time tables.

 

Can you show an example of the table containing the numerical values (10, 10, 20, 20 etc)?

I just want to make sure I give a suggestion consistent with how your data is set up.


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Hi @OwenAuger 

i attached sample data and screenshot that i want to retrun

working time = raw * 30

for example W01 part a's project1 has 5 rows so 150(Minutes)

 

[raw data]

COU_Alan_1-1740319955985.png

[result]

COU_Alan_0-1740319856183.png

Thank you 🙂

Hi @COU_Alan 

It looks like it's easier to treat Latest Comment as a static column, if that meets your requirements.

Then you can included it as a Row field in a matrix like this:

Latest Comment Column = 
CALCULATE (
    CALCULATE (
        CONCATENATEX ( Data, Data[comment], "|" ),
        TOPN ( 1, SUMMARIZE ( Data, Data[date], Data[time] ), Data[date] + Data[time], DESC )
    ),
    ALLEXCEPT ( Data, Data[part], Data[project_name] )
)

OwenAuger_0-1740434421731.png

It's much easier to place "supplementary" columns on the left (if they are static) as Row fields. Placing them on the right requires some adjustments to the model.

 

Would this work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.