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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Adidas
Helper I
Helper I

Calculate the corresponding price for the latest date in another column

I'm trying to calculate the corresponding price for the latest date in another column.

In this example each group has few items, each item has its own purchase date and price.

My goal is to calculate for each group the latest date and the corresponding price

(Which is not the max price for the group)

Any suggestions, please?

The source table and the desired result:

GroupItem CodeItem Purchase DateItem Price
A11115/01/2019200
A11215/02/2019180
A11315/03/2019150
B21110/02/2018180
B21210/03/2018120
B21310/04/2018140

 

GroupMax Purchase DateItem Price
A15/03/2019150
B10/04/2018140
1 ACCEPTED SOLUTION
carlomoretto
Frequent Visitor

Hi!

 

You can create a measure for the latest price and do without a measure for the latest date by using a variable instead, as suggested here:

https://community.powerbi.com/t5/Desktop/Needing-a-measure-for-last-sales-price/td-p/228280

 

Latest Price =

var MaxDate = CALCULATE(MAX(Table[Item Purchase Date]);ALLEXCEPT(Table;Tabella1[Group]))
return
CALCULATE(SUM(Table[Item Price]);FILTER(Table;Table[Item Purchase Date]=MaxDate))
 
Then you will get something like this:
Latest group price by purchase dateLatest group price by purchase date
 
Cheers!

 

 

View solution in original post

2 REPLIES 2
carlomoretto
Frequent Visitor

Hi!

 

You can create a measure for the latest price and do without a measure for the latest date by using a variable instead, as suggested here:

https://community.powerbi.com/t5/Desktop/Needing-a-measure-for-last-sales-price/td-p/228280

 

Latest Price =

var MaxDate = CALCULATE(MAX(Table[Item Purchase Date]);ALLEXCEPT(Table;Tabella1[Group]))
return
CALCULATE(SUM(Table[Item Price]);FILTER(Table;Table[Item Purchase Date]=MaxDate))
 
Then you will get something like this:
Latest group price by purchase dateLatest group price by purchase date
 
Cheers!

 

 

Thanks, it works!

 

this works also:

 

price of max date =
CALCULATE(
MIN(table[Item Price]),
FILTER(table,table[Item Purchase Date] = MAX(table[Item Purchase Date]))

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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