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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Qotsa
Helper V
Helper V

Track Progression of Employees First to X Weeks Hours Worked

Hi,

 

Goal is to show employees hrs worked from the first week where they have worked onwards.

 

Desired Output Matrix Column Headings are the 1st, 2nd instance etc that they worked in a given Week.

Every Employee has a 1st Wk Hrs Worked value but may not have values subsequently.

 

I have this measure that gives a running total of the number of weeks in which they have worked.

Weeks Worked =

SUMX(
    FILTER(
        SUMMARIZE(        
            'Data_Table',
          'Data_Table',[Employee_id],
            'Data Table'[Week]
       ) ,
        'Data_Table[Employee_id] <> BLANK()
    )
    ,1
)
 
but struggling to get to my desired output.
 
Qotsa_1-1671626866825.png

 

 

Data -> https://1drv.ms/x/s!AiX0_cACeSxJgSw4iLbtYaaP5nWt?e=vFYNb2

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can use the new INDEX function, but you need to make sure that the ORDERBY column is consistent - some of the values have a space between the Wk and the number, some don't.

First week = 
CALCULATE(
	SUM( 'Table'[Hrs Worked]),
	INDEX( 1,, ORDERBY( 'Table'[Week & Year] ), KEEP, PARTITIONBY( 'Table'[Employee_id] ) )
)

You would need to replicate this measure for subsequent weeks, just change the 1 to 2, 3 etc. Or you could put it into  a calculation group.

View solution in original post

2 REPLIES 2
Qotsa
Helper V
Helper V

@johnt75 That works fantastically well. TY.

johnt75
Super User
Super User

You can use the new INDEX function, but you need to make sure that the ORDERBY column is consistent - some of the values have a space between the Wk and the number, some don't.

First week = 
CALCULATE(
	SUM( 'Table'[Hrs Worked]),
	INDEX( 1,, ORDERBY( 'Table'[Week & Year] ), KEEP, PARTITIONBY( 'Table'[Employee_id] ) )
)

You would need to replicate this measure for subsequent weeks, just change the 1 to 2, 3 etc. Or you could put it into  a calculation group.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.