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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JorgeCervantes
Frequent Visitor

How to get the last price you got in a product.

Hi Everyone:

 

So I'm having the following issue, I have a table with multiple products that have been purchased in different prices troughout the years. I've made a calculated table to have the single values for the products and the last date a product was bought each year, now I want to know the price according to that last date the product was purchased on. Something like this:

 

I want to transform this: 

 

Date   Product  Price
9/10/2023   Product A  15
11/16/2023   Product A  12
12/12/2023   Product A  14
7/5/2023   Product B  13
8/8/2023   Product B  15

 

Into this:

Product   Last Date 2023   Last Price 2023
Product A   12/12/2023   14
Product B    8/8/2023   15

 

Does anyone know how can I solve this? I have tried with LOOKUPVALUES, FIRSTVALUE and LASTVALUE, but I still can't find the solution.

 

Thank you.

1 ACCEPTED SOLUTION
Daniel29195
Super User
Super User

@JorgeCervantes 

output

Daniel29195_0-1710887675917.png

 

 

 

calculated table : 

new_tbl = 
ADDCOLUMNS(
    VALUES(tbl[   Product]),
"latest date" , CALCULATE(MAX(tbl[Date]))
)

 

 

calculated col : 

cooresponding price = 
MAXX(FILTER(tbl, tbl[   Product] = new_tbl[   Product] && tbl[Date] = new_tbl[latest date]),tbl[  Price])

 

 

hope this helps .

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🙏

View solution in original post

1 REPLY 1
Daniel29195
Super User
Super User

@JorgeCervantes 

output

Daniel29195_0-1710887675917.png

 

 

 

calculated table : 

new_tbl = 
ADDCOLUMNS(
    VALUES(tbl[   Product]),
"latest date" , CALCULATE(MAX(tbl[Date]))
)

 

 

calculated col : 

cooresponding price = 
MAXX(FILTER(tbl, tbl[   Product] = new_tbl[   Product] && tbl[Date] = new_tbl[latest date]),tbl[  Price])

 

 

hope this helps .

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🙏

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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