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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
JeremyKeith
Frequent Visitor

PowerBI assistance creating a Measure to count the number of Like Occurances per ID

I am looking for a particular case to identify users in a large data set that are missing a expected roles role.

 

In the below example I have 3 users in my data set but the actual source is much larger. I ultimately would like to have a Measure or calculated column that returns either 0 for none or a count of of the filtered columns.

 

Example data 

 

Last NameFirst NameUser IdRole
DoeJohndoejBuilding Access
DoeJohndoejSpecial: Active Directory
DoeJohndoejSpecial: Oracle
SmithJoesmithj1220000001
SmithJoesmithj12Security Professional
SmithJoesmithj12Security Administrator
SmithJoesmithj12Building Access
SmithJoesmithj12Customer Service
JonesJennyjonesj220000150
JonesJennyjonesj220000150-U
JonesJennyjonesj2Building Access
JonesJennyjonesj2General Accounting
JonesJennyjonesj2Accounting Processor

 

In most cases users will only have one of these special roles and it will always start with 20, but there are some split roles that have 2. But as you can see John Doe in this example doesnt have a Numeric role listed and what I hope to be able to identify easier these. 

 

My ideal data output would be like the following.

User IdEmployee Role Detected
doej0
smithj121
jonesj22

 

With  a measure I would be able to filter for Zero and identify what users do not have one of these 20 Roles. I may be thinking of this as a harder way that I need to  but I am still new to the tool so appritiate any help. I have tried various things but I have not made meaning full progress could anyone point to a example of the best way to do this.

2 ACCEPTED SOLUTIONS
sturlaws
Resident Rockstar
Resident Rockstar

Hi @JeremyKeith ,

 

assuming I understand your requirements correct, you can write this measure:

Measure =
VAR _tmp =
    CALCULATE (
        COUNTROWS ( 'Table' );
        FILTER ( 'Table'; LEFT ( 'Table'[Role]; 2 ) = "20" )
    )
RETURN
    IF ( NOT ( ISBLANK ( _tmp ) ); _tmp; 0 )

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

View solution in original post

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @JeremyKeith ,

 

try this

Employee Role Detected =
IF (
    ISBLANK (
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER ( 'Table', LEFT ( 'Table'[Role], 2 ) = "20" )
        )
    ),
    "No 20 role",
    BLANK ()
)

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

5 REPLIES 5
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @JeremyKeith ,

 

try this

Employee Role Detected =
IF (
    ISBLANK (
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER ( 'Table', LEFT ( 'Table'[Role], 2 ) = "20" )
        )
    ),
    "No 20 role",
    BLANK ()
)

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


@mwegener 

 

This looks like it will do what I need.

 

Thanks for the help

mwegener
Most Valuable Professional
Most Valuable Professional

@JeremyKeith 

If I answered your question, please mark my post as solution, this will also help others.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


sturlaws
Resident Rockstar
Resident Rockstar

Hi @JeremyKeith ,

 

assuming I understand your requirements correct, you can write this measure:

Measure =
VAR _tmp =
    CALCULATE (
        COUNTROWS ( 'Table' );
        FILTER ( 'Table'; LEFT ( 'Table'[Role]; 2 ) = "20" )
    )
RETURN
    IF ( NOT ( ISBLANK ( _tmp ) ); _tmp; 0 )

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

@sturlaws Thanks for the responce it is appritiated.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors