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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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.LearnAndPractise(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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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