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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Tmk123
Helper II
Helper II

DAX formula to return most recent cost for SKU

Hi, 

I am trying to create a measure "Latest Cost" that takes the most recent cost for a SKU based on the Invoice Date.  

 

I am trying to find these values for the sample data below:

ABC123 = $30.20

XYZ123 = $50.20

BBB123 = $30.90

 

Supplier SKUInvoice DatePurchase Unit Price
ABC12312/22/2022$37.95
ABC1231/16/2023$34.95
ABC12311/9/2023$30.20
XYZ12310/16/2023$50.20
XYZ1239/29/2023$45.20
XYZ1238/31/2023$65.20
BBB1238/25/2023$30.90
BBB1238/11/2023$31.00
2 ACCEPTED SOLUTIONS
amustafa
Super User
Super User

Adjust the table name in the following DAX Measure:

 

Latest Unit Price =
VAR MaxInvoiceDate = CALCULATE(MAX('SKU'[Invoice Date]), ALLEXCEPT('SKU', 'SKU'[Supplier SKU]))
RETURN
    CALCULATE(MAX('SKU'[Purchase Unit Price]), FILTER('SKU', 'SKU'[Invoice Date] = MaxInvoiceDate))
 
If I answered your question, please mark this thread as accepted.
Follow me on LinkedIn:
https://www.linkedin.com/in/mustafa-ali-70133451/




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

ThxAlot
Super User
Super User

ThxAlot_1-1704491486863.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

5 REPLIES 5
ThxAlot
Super User
Super User

ThxAlot_1-1704491486863.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Thank you!!

tamerj1
Super User
Super User

Hi @Tmk123 
Please try

Latest Cost =
SUMX (
    VALUES ( 'Table'[Supplier SKU] ),
    MAXX (
        TOPN ( 1, CALCULATETABLE ( 'Table' ), 'Table'[Invoice Date] ),
        'Table'[Purchase Unit Price]
    )
)
amustafa
Super User
Super User

Adjust the table name in the following DAX Measure:

 

Latest Unit Price =
VAR MaxInvoiceDate = CALCULATE(MAX('SKU'[Invoice Date]), ALLEXCEPT('SKU', 'SKU'[Supplier SKU]))
RETURN
    CALCULATE(MAX('SKU'[Purchase Unit Price]), FILTER('SKU', 'SKU'[Invoice Date] = MaxInvoiceDate))
 
If I answered your question, please mark this thread as accepted.
Follow me on LinkedIn:
https://www.linkedin.com/in/mustafa-ali-70133451/




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks so much!

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.