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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Get Value corresponding to max date over Primary Key

Hello Team,

 

I am fairly new to Power BI and I am stuck with a logic where i have to Get the value from a column based on max date of each request.

 

My Tables consist of a Request table connected to a Comments table. Both tables are connected with each other by a One to Many relationship, The request table has ID column as Primary key and comments table has the relevant comments for the ID.

 

I want to display the latest comments for each ID in a Table Box.

 

Thank you,

Siddhesh H Mane.

1 ACCEPTED SOLUTION

Hi @Anonymous 

Create two measures in comments table,

Max date = CALCULATE(MAX('Comments table'[date]),ALLEXCEPT('Comments table','Comments table'[ID]))

flag = IF(MAX('Comments table'[date])=[Max date],1,0)

Add [flag] in the visual level filter

7.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Does two tables look like this?

Request table

ID
1
2
3

 

Comments table

ID date comment
1 5/1/2019 comment11
1 5/2/2019 comment12
1 5/3/2019 comment13
2 5/1/2019 comment21
2 5/2/2019 comment22
2 5/3/2019 comment23
3 5/1/2019 comment31
3 5/2/2019 comment32
3 5/3/2019 comment33

 

Request table (relationship: one to many) Comments table

 

Finally, the output should be as follows:

Get the value from a column based on max date of each request

ID date comment
1 5/3/2019 comment13
2 5/3/2019 comment23
3 5/3/2019 comment33

 

Is my understanding correct?

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @v-juanli-msft ,

 

Thank you for helping me out. Yes this is how the output should be.

 

Thank you,

Siddhesh H Mane.

Hi @Anonymous 

Create two measures in comments table,

Max date = CALCULATE(MAX('Comments table'[date]),ALLEXCEPT('Comments table','Comments table'[ID]))

flag = IF(MAX('Comments table'[date])=[Max date],1,0)

Add [flag] in the visual level filter

7.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @v-juanli-msft ,

 

Thanks a lot, will definitely try this one out. I had tried using the below DAX to display the output for the time being

 

Latest Comments = MAXX(FILTER(RequestComments, RequestComments[RequestId] && RequestComments[Created] = MAX(RequestComments[Created])), RequestComments[Comments])
 
I don't know exactly if this is the right approach, but i was getting the desired output.
Please let me know if this is correct.
 
Thanks a lot,
Siddhesh H Mane.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.