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

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

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

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

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors