Forum Discussion

hgzelaya's avatar
hgzelaya
Icon for Helper I rankHelper I
5 years ago
Solved

Is this even possbile?

hi everyone! i have the following table ID DATE ITEMS PURCHASED AVERAGE OF ITEMS PURCHASED IN THE LAST 2 MONTH BY ID 1 mar-21 10 20 1 abr-21 20 20 1 may-21 20 20 2 jun-21...
  • mahoneypat's avatar
    5 years ago

    Once you convert your mmm-yy column to a Date type, you can use this column expression to get your result.

     

    Last Two Avg =
    VAR thisID = Items[ID]
    VAR Last2Rows =
        TOPN ( 2FILTER ( Items, Items[ID] = thisID ), Items[DATE], DESC )
    RETURN
        AVERAGEX ( Last2Rows, Items[ITEMS PURCHASED] )

     

    Pat