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
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

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


View solution in original post

5 REPLIES 5

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


@mwegener 

 

This looks like it will do what I need.

 

Thanks for the help

@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


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
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.