Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MICOLSCOTT
New Member

Is there a way to assign a sequence # column to a table within powerbi based on data in several col?

I'm relatively new working with PowerBI and know how I would do this in SQL, but in this instance I already have the data set in a PowerBI table and wondered if there is a way to do this within PowerBI.

 

SQL equivalent: ROW_NUMBER() OVER(PARTITION BY WORK_DATE, EMP_ID) ORDER BY TASK_START_TS, EMP_ID, WORK_DATE ASC)

 

Example: I have a table 'TASKS' with data like below, which has employees and a list of their tasks for the day with the time they started each task.

 

EMP_ID

TASK_IDTASK_TYPEWORK_DATETASK_START_TSTASK_COMPLETE_TS
emp071286511Service11/12/201911/12/19 12:15 PM11/12/19 3:00 PM
emp071286564Repair11/12/201911/12/19 8:00 AM11/12/19 10:00 AM
emp003286732Service11/13/201911/13/19 8:00 AM11/13/19 9:20 AM
emp003286771Repair11/12/201911/12/19 8:00 AM11/12/19 11:00 AM
emp003286794Repair11/12/201911/12/19 11:30 AM11/12/19 3:00 PM
emp071286795Repair11/13/201911/13/19 11:45 AM11/13/19 2:00 PM
emp071286954Service11/13/201911/13/19 8:00 AM11/13/19 11:00 AM
emp071386145Service11/12/201911/12/19 10:01 AM11/12/19 12:10 PM
emp003395614Service11/13/201911/13/19 1:00 PM11/13/19 7:00 PM
emp003453262Repair11/13/201911/13/19 9:30 AM11/13/19 12:30 PM

 

I want to know if there is a way to make a calculated column that will assign a sequence number for each task by EMP_ID and WORK_DATE and order by the TASK_START_TS timestamp in ascending order. Call the column TASK_SEQ_NUM, 1st task for the employee on that work date as 1, second task for the employee on that work date as 2, and so on. If there's a link to a tutorial or something I'd love to check it out. I have tried googling it all morning and haven't had much luck. Thanks

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @MICOLSCOTT 

Create a calculated column

Column =
RANKX (
    FILTER (
        'Table',
        'Table'[WORK_DATE] = EARLIER ( 'Table'[WORK_DATE] )
            && 'Table'[EMP_ID] = EARLIER ( 'Table'[EMP_ID] )
    ),
    [TASK_START_TS],
    ,
    ASC,
    DENSE
)

Capture16.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @MICOLSCOTT 

Create a calculated column

Column =
RANKX (
    FILTER (
        'Table',
        'Table'[WORK_DATE] = EARLIER ( 'Table'[WORK_DATE] )
            && 'Table'[EMP_ID] = EARLIER ( 'Table'[EMP_ID] )
    ),
    [TASK_START_TS],
    ,
    ASC,
    DENSE
)

Capture16.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Worked perfectly! Thank you @v-juanli-msft !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.