Forum Discussion

MWare's avatar
MWare
Icon for Helper I rankHelper I
3 years ago
Solved

DAX Calculation to retrieve the entry before

Hi,

 

Looking for some help please.

 

I am trying to return the previous 'Sale time' based on the 'Sales Person' of each row in my 'Sales' table.

Unfortunatley the index is based on all sales in the shop and thus I can't use -1 on the index as the Sales Person can vary.

See below image in Power BI, the DAX formula I have created using EARLIER in column 'Prior Sales Time (DAX Help)' is not returning the prior sales time for the sales person for the row.  See the 'Prior Sales Time (the answer I'm after)' column for what the value I'm expecting in my DAX formula.

 

Any ideas? 

 

  • =MAXX(FILTER(Sales,Sales[Sale Person]=EARLIER(Sales[Sale Person])&&Sales[Sale Time]<EARLIER(Sales[Sale Time])),Sales[Sale Time])

2 Replies

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

    =MAXX(FILTER(Sales,Sales[Sale Person]=EARLIER(Sales[Sale Person])&&Sales[Sale Time]<EARLIER(Sales[Sale Time])),Sales[Sale Time])