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
Bebecirux
Frequent Visitor

Help to get the last cost of an item

Good evening, I have the following question, how can I generate a dax in powerbi desktop that brings me the last FOB cost of the item by supplier, because I need to compare my last purchase price with the new lists to find out if there are price increases or decreases, I hope can you help me thank you very much

 

 

Captura de pantalla 2023-04-03 235235.jpg

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Bebecirux ,

You can create a measure as below to get it, please find the details in the attachment.

Measure =
VAR _selsupplier =
    SELECTEDVALUE ( 'Table'[Proveedor] )
VAR _selitem =
    SELECTEDVALUE ( 'Table'[Artículo] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Fecha] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Proveedor] = _selsupplier
                && 'Table'[Artículo] = _selitem
        )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[FOB] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Proveedor] = _selsupplier
                && 'Table'[Artículo] = _selitem
                && 'Table'[Fecha] = _maxdate
        )
    )

vyiruanmsft_0-1681959911547.png

Best Regards

Community Support Team _ Rena
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

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @Bebecirux ,

You can create a measure as below to get it, please find the details in the attachment.

Measure =
VAR _selsupplier =
    SELECTEDVALUE ( 'Table'[Proveedor] )
VAR _selitem =
    SELECTEDVALUE ( 'Table'[Artículo] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Fecha] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Proveedor] = _selsupplier
                && 'Table'[Artículo] = _selitem
        )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[FOB] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Proveedor] = _selsupplier
                && 'Table'[Artículo] = _selitem
                && 'Table'[Fecha] = _maxdate
        )
    )

vyiruanmsft_0-1681959911547.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ryan_mayu
Super User
Super User

@Bebecirux 

pls provide the sample data(not the screenshot) and the expected output





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

Proud to be a Super User!




Ritaf1983
Super User
Super User

Hi @Bebecirux ,
Here is what I think can help you, if I understand you correctly:
https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0https://...

If my answer was helpful please give me a Kudos and accept as a Solution.

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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