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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dwhittaker1
Helper II
Helper II

Return value based on the latest sales price

The table below contains an ItemID with multiple sales prices. I would like to create a measure that only shows me the last sales price for an ItemID. For example the meausre would return a sales price oF 120 for ItemID A and it would return  a sales price of 90 for Item B.

 

ITEMID comes from the DIMITEM table

ITEMNAME comes from the DIMITEM table

PARTFAMILY comes from the DIMITEM table

SALESPRICE comes from the factsalesinvoice table

DATE comes from the DIMDATE table

 

 

ItemIDItemNamePart FamilySalesPriceDate
ATire1210012/1/2024
ATire1210512/10/2024
ATire1111011/12/2024
ATire1212012/23/2024
BRoad15951/1/2024
BRoad14901/12/2024
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

Thanks for the solutions darkniqht  and SamWiseOwl  offered and i want to offer some more information for user to refer to.

hello @dwhittaker1 , you can create a measure.

 

MEASURE =
VAR a =
    CALCULATE (
        MAX ( factsalesinvoice[Date] ),
        ALLSELECTED ( factsalesinvoice ),
        factsalesinvoice[ItemID] IN VALUES ( DIMITEM[ItemID] )
    )
RETURN
    CALCULATE (
        SUM ( factsalesinvoice[SalesPrice] ),
        FILTER ( DIMDATE, DIMDATE[Date] = a )
    )

 

Output

vxinruzhumsft_0-1730339827787.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi,

Thanks for the solutions darkniqht  and SamWiseOwl  offered and i want to offer some more information for user to refer to.

hello @dwhittaker1 , you can create a measure.

 

MEASURE =
VAR a =
    CALCULATE (
        MAX ( factsalesinvoice[Date] ),
        ALLSELECTED ( factsalesinvoice ),
        factsalesinvoice[ItemID] IN VALUES ( DIMITEM[ItemID] )
    )
RETURN
    CALCULATE (
        SUM ( factsalesinvoice[SalesPrice] ),
        FILTER ( DIMDATE, DIMDATE[Date] = a )
    )

 

Output

vxinruzhumsft_0-1730339827787.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

darkniqht
Advocate I
Advocate I

To create a measure that returns the latest sales price for each ItemID, you can use a DAX formula in Power BI or a similar tool. Here’s a simple way to do it:

  1. Sort by Date: Ensure your sales data is sorted by date in descending order.

  2. Create the Measure:

    DAX
     

 

LatestSalesPrice = 
CALCULATE(
    LASTNONBLANK(factsalesinvoice[SalesPrice], 1),
    FILTER(
        factsalesinvoice,
        factsalesinvoice[ItemID] = SELECTEDVALUE(DIMITEM[ItemID])
    )
)

 

This measure will give you the most recent sales price for each ItemID based on the latest date in your data. Just make sure to adjust the table and column names if they differ in your model!

SamWiseOwl
Super User
Super User

Hi @dwhittaker1 

Most Reccent Price =
var maxDate = Calculate(LastDate(DIMDATE[Date]), All(DimItem[PARTFAMILY]))

Return
Calculate( Max(factsalesinvoice[SALESPRICE]), DIMDATE[Date] = maxDate)

Give that a whirl 🙂


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

@SamWiseOwl  thanksfor the help but the measure is i identifying the latest sales price its just replicating the current sales price. Also I would like to exclude the date from my table visual

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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