Forum Discussion

schoden's avatar
schoden
Icon for Post Partisan rankPost Partisan
5 years ago
Solved

FIRSTDATE and LASTDATE Functions

Hi Community, 

 

I am trying to get only the  FIRST order of a customer. A customer can have many orders. 

 

The measure created is : 

CALCULATE(MIN('Date'[DateOrdered]),ALL(Date'[Date]))
 
Now that I got all the first orders of a customer , how do I filter all the first date based on slicer selection date( using the ALL function ignores the filter applied ) 
 
 
Slicer date shows Aug 2020, so first date filters only for Aug 2020 too. See the pic (expected result) 
 
 
Thanks in advance. 
 

 

 

 

  • Thank you community , I searched past post and came across post that helped me solve it.

     

    I wrote another measure as a 

     

     Check =
    var datecheck= MIN('Date'[Date])
    Return
    IF( [FirstOrder]= datecheck, 1, 0)  
     
    With this check set as 1, It returns all FIRST DATE of a customer that is same to the slicer Selection date.
     
    Cheers.
     
     

3 Replies

  • schoden , These two should able to give you the same

     

    CALCULATE(MIN('Date'[DateOrdered]),ALLselected('Date'[Date]))

    or
    firstnonbank('Date'[DateOrdered],blank())

    • schoden's avatar
      schoden
      Icon for Post Partisan rankPost Partisan

      amitchandak  yes all you mentioned it gives all first date order of a customer.

       

      BUT now I want to filter those first date based on slicer date selected.

      Slicer chosen is AUg 2020 but first date shows all record of First date for a customer from 2009 also.

       

       

       

      • schoden's avatar
        schoden
        Icon for Post Partisan rankPost Partisan

        Thank you community , I searched past post and came across post that helped me solve it.

         

        I wrote another measure as a 

         

         Check =
        var datecheck= MIN('Date'[Date])
        Return
        IF( [FirstOrder]= datecheck, 1, 0)  
         
        With this check set as 1, It returns all FIRST DATE of a customer that is same to the slicer Selection date.
         
        Cheers.