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
MatthewUK
New Member

How to calculate a value from one column based on another column's maximum value

I have table as shown below. For each Reference, there may be multiple rows at different dates. I want to be able to create a calculated column that will evaluate, for each Reference, the value of the Count field where the Date is the maximum for that Reference (ie not just the maximum date in the table as a whole) Is this possible?

 

ReferenceCountDate
A10601/10/2020
A8101/10/2021
B301/11/2022
B1701/11/2020
B1801/11/2023
B1501/11/2021
C1910/07/2023
C1901/11/2022
D5101/06/2021
D5801/06/2023
E201/04/2021
E201/04/2022
E2301/07/2021

 

What I am aiming for is:

ReferenceResult
A81
B18
C19
D58
E2

 

Many thanks for any help for this !

1 ACCEPTED SOLUTION
grazitti_sapna
Super User
Super User

Hi @MatthewUK ,
You can achieve this by using:- 
Result =
VAR MaxDate = CALCULATE(MAX('YourTable'[Date]), ALLEXCEPT('YourTable', 'YourTable'[Reference]))
RETURN
CALCULATE(MAX('YourTable'[Count]), 'YourTable'[Date] = MaxDate)


Hope this will help you.
Thank you 

View solution in original post

3 REPLIES 3
MatthewUK
New Member

 thank you so much - I'd tried loads of answers from similar questions and failed but this has worked a treat!

Thank you @MatthewUK 

grazitti_sapna
Super User
Super User

Hi @MatthewUK ,
You can achieve this by using:- 
Result =
VAR MaxDate = CALCULATE(MAX('YourTable'[Date]), ALLEXCEPT('YourTable', 'YourTable'[Reference]))
RETURN
CALCULATE(MAX('YourTable'[Count]), 'YourTable'[Date] = MaxDate)


Hope this will help you.
Thank you 

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.