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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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