Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Add a sequence number by ID and date/time

I have a table with an alphanumeric ID field and a modified date & time field. I need another column that assigns a sequence numer by ID and date/time. 

 

So this:

IDModified Date
INC0000019148628/9/2017 16:27
INC0000019148628/9/2017 18:04
INC0000019148628/9/2017 20:22
INC0000019148628/9/2017 22:39
INC0000019148628/10/2017 15:21
INC0000019167688/12/2017 16:07
INC0000019167688/12/2017 16:25
INC0000019167688/12/2017 16:27
INC0000019167688/12/2017 16:32
INC0000019167688/12/2017 18:37

 

Needs to return this:

IDModified DateSequence
INC0000019148628/9/2017 16:271
INC0000019148628/9/2017 18:042
INC0000019148628/9/2017 20:223
INC0000019148628/9/2017 22:394
INC0000019148628/10/2017 15:215
INC0000019167688/12/2017 16:071
INC0000019167688/12/2017 16:252
INC0000019167688/12/2017 16:273
INC0000019167688/12/2017 16:324
INC0000019167688/12/2017 18:375

 

Thoughts?

  • Anonymous's avatar
    Anonymous
    7 years ago

    Can add this as a calculated column:

    Sequence = 
    VAR CurrentID= Table1[ID]
    VAR CurrentDate = Table1[Modified Date]
    RETURN
    
    CALCULATE(
        COUNTROWS( Table1 ),
        FILTER ( 
            ALL( Table1 ),
            CurrentID = Table1[ID]
            && CurrentDate >= Table1[Modified Date]
        )
    )

     

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Can add this as a calculated column:

    Sequence = 
    VAR CurrentID= Table1[ID]
    VAR CurrentDate = Table1[Modified Date]
    RETURN
    
    CALCULATE(
        COUNTROWS( Table1 ),
        FILTER ( 
            ALL( Table1 ),
            CurrentID = Table1[ID]
            && CurrentDate >= Table1[Modified Date]
        )
    )

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Works perfect, thanks!

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous  is there a way to allow duplicate numbers in the sequence? I have a table with multiple rows for the same ID and date and want these to have the same sequence value.

       

      Thanks