Forum Discussion

guvhahsya's avatar
guvhahsya
New Member
3 years ago
Solved

Define Last Purchase Before the Last Purchase

Hi guys I need some help with this problem. Username A bought our products on the written dates in the picture (including 16 August). Is there a DAX so that "Last Purchase Date" shows 8 August and not 16 August (2nd last purchase date)? Thanks so much!
This is my DAX for now

Last Purchase Date =
CALCULATE(
    MAX(SHOPEE[Waktu Pembayaran Dilakukan]),
    FILTER(
        SHOPEE,
        SHOPEE[Username] = EARLIER(SHOPEE[Username]) &&
        SHOPEE[Waktu Pembayaran Dilakukan] < EARLIER(SHOPEE[Username])
    )
)
  • Hi,

    Here is one way to do this:

     

    Last purchase = var _date = MAX('Table (30)'[Purchase Date]) return


    CALCULATE(MAX('Table (30)'[Purchase Date]),ALL('Table (30)'[Purchase Date]),'Table (30)'[Purchase Date]<_date)

    End result:



    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/



2 Replies

  • ValtteriN's avatar
    ValtteriN
    Icon for Community Champion rankCommunity Champion

    Hi,

    Here is one way to do this:

     

    Last purchase = var _date = MAX('Table (30)'[Purchase Date]) return


    CALCULATE(MAX('Table (30)'[Purchase Date]),ALL('Table (30)'[Purchase Date]),'Table (30)'[Purchase Date]<_date)

    End result:



    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/