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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
DRNEWTR
Frequent Visitor

last price change date measure

Hi how can i calculated last price change date

 

    How can i calculate in dax
RecidINVOICE_DATEProduct_NumberPurchise_PriceLast Purchise Change Date
150016.04.2024AS.124851009.04.2024
149915.04.2024AS.124851009.04.2024
149813.04.2024AS.124851009.04.2024
149712.04.2024AS.124851009.04.2024
149611.04.2024AS.124851009.04.2024
149509.04.2024AS.124851009.04.2024
149408.04.2024AS.124847027.03.2024
149306.04.2024AS.124847027.03.2024
149205.04.2024AS.124847027.03.2024
149104.04.2024AS.124847027.03.2024
149003.04.2024AS.124847027.03.2024
148902.04.2024AS.124847027.03.2024
148801.04.2024AS.124847027.03.2024
148730.03.2024AS.124847027.03.2024
148629.03.2024AS.124847027.03.2024
148528.03.2024AS.124847027.03.2024
148427.03.2024AS.124847027.03.2024
148326.03.2024AS.124845007.03.2024
148225.03.2024AS.124845007.03.2024
148123.03.2024AS.124845007.03.2024
148022.03.2024AS.124845007.03.2024
147921.03.2024AS.124845007.03.2024
147820.03.2024AS.124845007.03.2024
147719.03.2024AS.124845007.03.2024
147618.03.2024AS.124845007.03.2024
147516.03.2024AS.124845007.03.2024
147415.03.2024AS.124845007.03.2024
147314.03.2024AS.124845007.03.2024
147213.03.2024AS.124845007.03.2024
147112.03.2024AS.124845007.03.2024
147011.03.2024AS.124845007.03.2024
146909.03.2024AS.124845007.03.2024
146808.03.2024AS.124845007.03.2024
146707.03.2024AS.124845007.03.2024
1 ACCEPTED SOLUTION
amustafa
Super User
Super User

Hi @DRNEWTR I suspect that you are trying to capture the invoice date when the purchase price is changed for each product. I sorted the data by Recid and created a calculated DAX column to get your desired results. See the attached .pbix file.

Last Purchase Change Date (DAX) = 
VAR CurrentRecid = 'Table'[Recid]
VAR CurrentPrice = 'Table'[Purchase_Price]
VAR CurrentProduct = 'Table'[Product_Number]
VAR PreviousPrice = CALCULATE(
    LASTNONBLANK('Table'[Purchase_Price], 1),
    FILTER(
        ALL('Table'),
        'Table'[Recid] < CurrentRecid
        && 'Table'[Product_Number] = CurrentProduct
    )
)
RETURN
IF(
    CurrentPrice <> PreviousPrice,
    'Table'[INVOICE_DATE],
    CALCULATE(
        MIN('Table'[INVOICE_DATE]),
        FILTER(
            ALL('Table'),
            'Table'[Recid] < CurrentRecid
            && 'Table'[Purchase_Price] = CurrentPrice
            && 'Table'[Product_Number] = CurrentProduct
        )
    )
)

 





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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ThxAlot
Super User
Super User

This is the scenario where WINDOW functions show the power.

 

ThxAlot_0-1713434056628.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


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


)



amustafa
Super User
Super User

Hi @DRNEWTR I suspect that you are trying to capture the invoice date when the purchase price is changed for each product. I sorted the data by Recid and created a calculated DAX column to get your desired results. See the attached .pbix file.

Last Purchase Change Date (DAX) = 
VAR CurrentRecid = 'Table'[Recid]
VAR CurrentPrice = 'Table'[Purchase_Price]
VAR CurrentProduct = 'Table'[Product_Number]
VAR PreviousPrice = CALCULATE(
    LASTNONBLANK('Table'[Purchase_Price], 1),
    FILTER(
        ALL('Table'),
        'Table'[Recid] < CurrentRecid
        && 'Table'[Product_Number] = CurrentProduct
    )
)
RETURN
IF(
    CurrentPrice <> PreviousPrice,
    'Table'[INVOICE_DATE],
    CALCULATE(
        MIN('Table'[INVOICE_DATE]),
        FILTER(
            ALL('Table'),
            'Table'[Recid] < CurrentRecid
            && 'Table'[Purchase_Price] = CurrentPrice
            && 'Table'[Product_Number] = CurrentProduct
        )
    )
)

 





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

Proud to be a Super User!




Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.