Forum Discussion

maurcoll's avatar
maurcoll
Helper IV
1 year ago
Solved

First/earliest Date

Hi 
i am trying to work out which is the earliest/First order date per customer as per the below. I have been trying to use the earlier function where the customer number = earlier customer number and order date = min order date but it doesn't seem to be working, i just get blanks.  I am trying to create it as a calculated column

var earliestdate = CALCULATE(MIN('customer'[Order Date]),
                        FILTER('customer', 'customer' [Customer Number] = EARLIER( 'customer' [Customer Number])))


RETURN
IF(Order Date = earliestdate , "First", BLANK())

Customer NumberOrder NumberOrder DateProduct NumberOrdered
1117/01/202512First
1117/01/202513First
1117/01/202514First
1220/01/202512 
1220/01/202515 
1220/01/202516 
2318/01/202521First
2318/01/202525First
2431/01/202526 
2425/01/202521 
2425/01/202525 
3518/01/202521First
3619/01/202523 
  • Hello maurcoll 

     

    Us this DAX to create calculated column

    Ordered =

    VAR EarliestDate =

        CALCULATE(

            MIN('customer'[Order Date]),

            ALLEXCEPT('customer', 'customer'[Customer Number])

        )

    RETURN

        IF('customer'[Order Date] = EarliestDate, "First", BLANK())

     

    Thanks,
     Pankaj Namekar | LinkedIn

    If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

2 Replies

  • Hello maurcoll 

     

    Us this DAX to create calculated column

    Ordered =

    VAR EarliestDate =

        CALCULATE(

            MIN('customer'[Order Date]),

            ALLEXCEPT('customer', 'customer'[Customer Number])

        )

    RETURN

        IF('customer'[Order Date] = EarliestDate, "First", BLANK())

     

    Thanks,
     Pankaj Namekar | LinkedIn

    If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

  • Sasidhar1's avatar
    Sasidhar1
    Regular Visitor

    Hi maurcoll , 

    Hope you are doing well.

    I can see there is no issue with  the dax what you have written and the output is also expected as we are having different dates for a customer number that was mapped to blank and for customer for min order date is mapped to First.

     

    Let us know what is the output you are expecting.

     

    Thanks