Forum Discussion

karlo's avatar
karlo
Frequent Visitor
6 years ago
Solved

DAX - Problem to identify previous record

Hi everyone,

 

I'm starting with DAX and I need your help, for a particular record I am trying to identify the previous record if the start date of the previous record is less. Also, if there is more than one record, sort them alphabetically and include them as groups.

 

For example, considering the following matrix:

 

IDCONTRACTSTARTPRODUCT
1101-01-2016A
2301-01-2016C
1401-01-2019B
2501-01-2017A
1601-01-2018C

 

The result with PRIVIOUS is:

 

IDCONTRACTSTARTPRODUCTPREVIOUS
1101-01-2016A 
2301-01-2016C 
1401-01-2019BA-C
2501-01-2017AC
1601-01-2018CA

 

I would greatly appreciate your help or comments, I have done several tests without good results. In some cases I have memory problems (I have 8GB RAM).

 

Thank you

Karlo

  • Anonymous's avatar
    Anonymous
    6 years ago

    karlo 
    Please create a measure 

    Measure = CALCULATE(CONCATENATEX('Table','Table'[PRODUCT],"-",'Table'[PRODUCT]),FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[START]<MAX('Table'[START])))

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    karlo 
    Please create a measure 

    Measure = CALCULATE(CONCATENATEX('Table','Table'[PRODUCT],"-",'Table'[PRODUCT]),FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[START]<MAX('Table'[START])))

     

    • karlo's avatar
      karlo
      Frequent Visitor

      Excellent vimal_parmar, I'll try again

       

      Thank you very much!