Forum Discussion

krdavies's avatar
krdavies
Helper I
2 months ago
Solved

Calculated column to assign numeric code to dates

Hello, 

 

I have a table with data tracking instances of clients contacting a support desk. My table has an instance id that is the unique identifier for each call, then the date of the call and the user who reached out. We have numerous calls on each day and I would like to assign a unique identifier to each date so I can use this as a date identifier and append this data to another table. I believe I can use a calculated column to do this but I don't know how to create a formula for it. 

 

Below is a sample table of what I currently have:

DateInstance IDUsername
2025-03-1010001anderson_marcus
2025-03-1010002bellamy_claire
2025-03-1010003chen_oliver
2025-03-1010004davidson_priya
2025-03-1010005everett_natasha
2025-03-1110006fletcher_dominic
2025-03-1110007anderson_marcus
2025-03-1110008bellamy_claire
2025-03-1110009irons_selene
2025-03-1110010jackson_rowan
2025-03-1210011chen_oliver
2025-03-1210012anderson_marcus
2025-03-1210013jackson_rowan
2025-03-1210014nguyen_callum
2025-03-1210015ortega_simone
2025-03-1310016patel_griffin
2025-03-1310017quinn_adriana
2025-03-1310018chen_oliver
2025-03-1310019anderson_marcus
2025-03-1310020thornton_jasper
  • Hi all, thank you for your input but it turns out there was actually a very easy way to do this in Power Query. Steps below: 

     

    1. Use the group by function on the date column, setting the operation to "all rows", making a nested table for each date. 

    2. Add an index column (I used the custom starting point of 99001 and incremented at 1)

    3. Expand the nested tables back out. 

     

    Each row now has a unique identifier based on its date!

11 Replies

  • Hi all, thank you for your input but it turns out there was actually a very easy way to do this in Power Query. Steps below: 

     

    1. Use the group by function on the date column, setting the operation to "all rows", making a nested table for each date. 

    2. Add an index column (I used the custom starting point of 99001 and incremented at 1)

    3. Expand the nested tables back out. 

     

    Each row now has a unique identifier based on its date!

    • krdavies's avatar
      krdavies
      Helper I

      Thank you for your reply. In trying this I'm getting a 'Token Literal Expected' error after ASC,. I am not sure how to correct this error. A screenshot is included wtih my table names covered up for confidentiality reasons: 

       

      • MasonMA's avatar
        MasonMA
        Super User

        You are in Power Query. The solution given to you is in Power BI. so go to Data View, select the table, choose New Column and paste the DAX formula there.

        Not in Transform Data / Power Query Editor.

    • krdavies's avatar
      krdavies
      Helper I

      pankajnamekar25 is there a way to do a similar function in Power Query? I need to use the column to perform an append query afterwards.