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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Resolver I
Resolver I

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
Resolver I
Resolver I

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.