Forum Discussion
hgzelaya
Helper I
5 years agoIs 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...
- 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 ( 2, FILTER ( Items, Items[ID] = thisID ), Items[DATE], DESC )
RETURN
AVERAGEX ( Last2Rows, Items[ITEMS PURCHASED] )Pat
mahoneypat
Microsoft Employee
5 years agoOnce 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 ( 2, FILTER ( Items, Items[ID] = thisID ), Items[DATE], DESC )
RETURN
AVERAGEX ( Last2Rows, Items[ITEMS PURCHASED] )
Pat
hgzelaya
Helper I
5 years agoWorked as needed. Thank you very much!