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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Rewrite Measure

I have the below measure.

 

Employee 5+ Jobs =
VAR newtable =
ADDCOLUMNS (
SUMMARIZE ( Employees, Employees[Employee Name] ),
"@jobcount", CALCULATE ( COUNTROWS ( VALUES ( 'Employees'[Job] ) ))
)
VAR filternewtable =
FILTER ( newtable, [@jobcount] >= 5 )
RETURN
IF( HASONEVALUE(Employees[Date] ),
COUNTROWS ( filternewtable ))
 
This measure looks at a table of jobs then summarizes a count where certain employees work 5+ jobs in one day.
 
I want to display this information in a table. This table would need to look like the following
 
DateEmployeeWorked Job 1 Worked Job 2 Worked Job 3 Worked Job 4Worked Job 5
       
       

 

Can this be achieved with any visualisations in Power BI?

1 ACCEPTED SOLUTION

Hi @Anonymous ,

Did you mean there's blank value in Job column like this?

vkalyjmsft_0-1644201451843.png

If this is the case, you can modify the formula of Rank like this:

Rank =
IF (
    'Table'[Job] = BLANK (),
    BLANK (),
    RANKX (
        FILTER (
            'Table',
            'Table'[Date] = EARLIER ( 'Table'[Date] )
                && 'Table'[Employee Name] = EARLIER ( 'Table'[Employee Name] )
                && 'Table'[Job] <> BLANK ()
        ),
        'Table'[Job],
        ,
        ASC,
        DENSE
    )
)

Then it can get the correct rank.

vkalyjmsft_1-1644201757101.png

Best Regards,
Community Support Team _ kalyj

 

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

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, it's hard to transform data to get the expected result in PowerQuery. Here's my solution:

1.Create a rank column.

Rank =
RANKX (
    FILTER (
        'Table',
        'Table'[Date] = EARLIER ( 'Table'[Date] )
            && 'Table'[Employee Name] = EARLIER ( 'Table'[Employee Name] )
    ),
    'Table'[Job],
    ,
    ASC,
    DENSE
)

Get the rank belong to the same date and same employee.

vkalyjmsft_0-1643363337753.png

2.Create measures.

Job1 = 
IF (
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] = MAX ( 'Table'[Date] )
                && 'Table'[Employee Name] = MAX ( 'Table'[Employee Name] )
        ),
        'Table'[Rank]
    ) >= 5,
    CALCULATE ( MAX ( 'Table'[Job] ), 'Table'[Rank] = 1 )
)
Job2 = 
IF (
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] = MAX ( 'Table'[Date] )
                && 'Table'[Employee Name] = MAX ( 'Table'[Employee Name] )
        ),
        'Table'[Rank]
    ) >= 5,
    CALCULATE ( MAX ( 'Table'[Job] ), 'Table'[Rank] = 2 )
)
Job3 = 
IF (
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] = MAX ( 'Table'[Date] )
                && 'Table'[Employee Name] = MAX ( 'Table'[Employee Name] )
        ),
        'Table'[Rank]
    ) >= 5,
    CALCULATE ( MAX ( 'Table'[Job] ), 'Table'[Rank] = 3 )
)
Job4 = 
IF (
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] = MAX ( 'Table'[Date] )
                && 'Table'[Employee Name] = MAX ( 'Table'[Employee Name] )
        ),
        'Table'[Rank]
    ) >= 5,
    CALCULATE ( MAX ( 'Table'[Job] ), 'Table'[Rank] = 4 )
)
Job5 = 
IF (
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] = MAX ( 'Table'[Date] )
                && 'Table'[Employee Name] = MAX ( 'Table'[Employee Name] )
        ),
        'Table'[Rank]
    ) >= 5,
    CALCULATE ( MAX ( 'Table'[Job] ), 'Table'[Rank] = 5 )
)

Get the expected result.

vkalyjmsft_1-1643363642362.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you very much for taking the time to look at my post.

 

This works great however where my data sometimes shows column 'Job' as null (blank), the formular counts this null row as a job. Is there anyway to exclude blanks from this?

 

Many thanks

Hi @Anonymous ,

Did you mean there's blank value in Job column like this?

vkalyjmsft_0-1644201451843.png

If this is the case, you can modify the formula of Rank like this:

Rank =
IF (
    'Table'[Job] = BLANK (),
    BLANK (),
    RANKX (
        FILTER (
            'Table',
            'Table'[Date] = EARLIER ( 'Table'[Date] )
                && 'Table'[Employee Name] = EARLIER ( 'Table'[Employee Name] )
                && 'Table'[Job] <> BLANK ()
        ),
        'Table'[Job],
        ,
        ASC,
        DENSE
    )
)

Then it can get the correct rank.

vkalyjmsft_1-1644201757101.png

Best Regards,
Community Support Team _ kalyj

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Anonymous ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi, 

 

Please see the attached excel document showing a sample piece of demo data and the desired output.

 

https://hertel-my.sharepoint.com/:x:/g/personal/elliot_serdet_altrad_com/ER9Iyrk0_CxHrrEmIO7sOFABRtI...

 

Many thanks

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

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.