For each client, get in every row, a column containing first purchase date

45 Views Asked by At

I am using Power BI (I can use only DAX).

Starting from this table:

Client Purchase Date
ClientA 01/01/2023
ClientA 01/02/2023
ClientB 01/03/2023
ClientB 01/02/2023

I would like to create a new column, called First Purchase Date that, for each client, keeps first purchase date, like:

Client Purchase Date First Purchase Date
Client A 01/01/2023 01/01/2023
Client A 01/02/2023 01/01/2023
Client B 01/03/2023 01/02/2023
Client B 01/02/2023 01/02/2023

How can I solve it using only DAX?

I tried to create

First Purchase Date = MINX(VALUES(Table1[Client]),MIN(Table2[Purchase Date]))

But it's like Third column is equal to second:

Client Purchase Date First Purchase Date
Client A 01/01/2023 01/01/2023
Client A 01/02/2023 01/02/2023
Client B 01/03/2023 01/03/2023
Client B 01/02/2023 01/02/2023
2

There are 2 best solutions below

0
Sam Nseir On

REMOVEFILTERS to remove the row context.

Try:

First Purchase Date =
  CALCULATE(
    MIN(Table2[Purchase Date]),
    REMOVEFILTERS(Table2[Purchase Date])
  )
0
mkRabbani On

You can try this below DAX for New Column-

First Purchase Date = 
CALCULATE(
    MIN(your_table_name[Purchase Date]),
    ALLEXCEPT(your_table_name, your_table_name[Client])
)