cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tomekm
Helper II
Helper II

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
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors