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
tomekm
Helper III
Helper III

Calculate overall ratio based on selected filter, including null values.

I’m trying to calculate a ratio for each employee ID, computed as the count of times they were selected for a project, divided by the count of times they were invited to a project.

 

Each employee ID’s ratio should be displayed when his employee ID is selected in a filter (and the overall ratio score to be shown in a score card or pie chart). Scenario below:

 

Employee ID ‘abc’ was invited to 2 projects. He wasn’t selected for project 1, so his ratio here is 0/1, but he was selected for the second project, so his ratio here is 1/1. Combined ratio should show 50% for this employee.

 

Here’s the sample data.

Project Name

Invited Employee

ID

Selected Employee

ID

project 1abcxyz
project 1abcdef
project 1xyzxyz
project 1xyzdef
project 1defxyz
project 1defdef
project 2abcabc
project 2xyzxyz

 

 

Invited Employee ID - filter:
abc

 

Desired output:

Overall Ratio:
50%

 

Thank you.

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @tomekm 

 

Try this measure:

Overall Ratio = 
VAR _SelINID =
    SELECTEDVALUE ( 'Table'[Invited Employee ID] )
VAR _Inv =
    DISTINCTCOUNT ( 'Table'[Project Name] )
VAR _Select =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Project Name] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Selected Employee ID] = _SelINID )
    )
RETURN
    _Select / _Inv

Output:

VahidDM_0-1635459486754.png

 

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

Appreciate your Kudos!!

 

View solution in original post

1 REPLY 1
VahidDM
Super User
Super User

Hi @tomekm 

 

Try this measure:

Overall Ratio = 
VAR _SelINID =
    SELECTEDVALUE ( 'Table'[Invited Employee ID] )
VAR _Inv =
    DISTINCTCOUNT ( 'Table'[Project Name] )
VAR _Select =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Project Name] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Selected Employee ID] = _SelINID )
    )
RETURN
    _Select / _Inv

Output:

VahidDM_0-1635459486754.png

 

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

Appreciate your Kudos!!

 

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.