Forum Discussion
Calculate Percentage value based on Slicer Selection
I have a list of Job Numbers and columns that determine whether a job meets any of 5 criteria (let's call them Criteria1-5)
I need to create a pie chart or even just a data card that shows what percentage of Job Numbers meet the selected criteria.
So, if I have 3 out of the 5 criteria slicers selected, what percentage of the total count of existing jobs meet this?
Example: there are 282 total jobs and 2 of them meet all 5 criteria. So when I have all 5 criteria slicers set to "Yes", I need something that shows me a value of "0.71%" and so on.
12 Replies
- erik_tarnvik
Solution Specialist
Assuming you have the criteria in a table called Criteria (I have called them "A"-"E") that you use for the slicer, and assuming the jobs are ina table called Jobs with criteria Columns containing boolean values (TRUE or FALSE) named A through E, the below should do it. The Criteria table can have no relationship with the Jobs table, and if you have other slicers involved it could require changes to the formula.
Percentage = COUNTROWS(FILTER(Jobs, IF(CONTAINS(Criteria,Criteria[Criteria],"A"), Jobs[A], TRUE) && IF(CONTAINS(Criteria,Criteria[Criteria],"B"), Jobs[B], TRUE) && IF(CONTAINS(Criteria,Criteria[Criteria],"C"), Jobs[C], TRUE) && IF(CONTAINS(Criteria,Criteria[Criteria],"D"), Jobs[D], TRUE) && IF(CONTAINS(Criteria,Criteria[Criteria],"E"), Jobs[E], TRUE)))/COUNTROWS(ALL(Jobs))
- bhmiller89
Helper V
I have them as columns in the Jobs Table as "Yes"/"No" Values
Job Number | Criteria 1| Critera 1...
- BILASolution
Solution Specialist
This way???
Total Jobs = CALCULATE(DISTINCTCOUNT(Job[Job Number]);ALL(Job))
Total Criteria = CALCULATE(DISTINCTCOUNT(Job[Job Number]);Job[Value] = "Yes")
Precentage = DIVIDE([Total Criteria];[Total Jobs])
Best Regards
BILAsolution
- bhmiller89
Helper V
I used your calculations:
Test%Total = COUNTROWS(FILTER(ActiveProjects, IF(CONTAINS(ActiveProjects, 'dpmgr vwJMWebJobSummary'[IsSOWHrs>300], "Yes"), ActiveProjects[Job Number], TRUE())&& IF(CONTAINS(ActiveProjects, 'dpmgr vwJMWebJobSummary'[IsLengthDays>180], "Yes"), ActiveProjects[Job Number], TRUE()) && IF(CONTAINS(ActiveProjects, 'dpmgr vwJMWebJobSummary'[IsActualEHR < $160], "Yes"), ActiveProjects[Job Number], TRUE()) && IF(CONTAINS(ActiveProjects, ActiveProjects[Is%HrsCompletion>75%], "Yes"), ActiveProjects[Job Number], TRUE()) && IF(CONTAINS(ActiveProjects, ActiveProjects[IsLastJR>60], "Yes"), ActiveProjects[Job Number], TRUE())))/COUNTROWS(ALL(ActiveProjects))
but I'm getting an error "Calculation error in measure.... Cannot convert value "2014-DLL-J27 (which is a job number), of type Text to type True/False"
- bhmiller89
Helper V
I think I know the bigger issue.
the criteria are stored in two different tables based on where each data point is kept.
I think I need to create a calculated table to pull in the JOb numbers and each column with criteria. I've never done that before.
If that's the case, could you provide me some guidance?
- erik_tarnvik
Solution Specialist
Hi bhmiller89,
I think you have mixed up the Criteria and the ActiveProject tables in your formula. The Criteria table needs to be separate from the ActiveProjects table and with no relationship with your ActiveProjects table, and is used for the slicer. Otherwise this wont work. With regards to some of the criteria being in different tables, the easiest way to resolve that is to create calculated columns that "pull in" the missing citeria to the ActiveProjects table.
- BILASolution
Solution Specialist
Hi bhmiller89
To solve your answer...
1. Data Sample (In my case, the table is called "Table 1")
2. Create the next measures...
Total Jobs = CALCULATE(DISTINCTCOUNT(Table1[Job Number]);ALL(Table1))
Total Criteria = DISTINCTCOUNT(Table1[Job Number])
Percentage = DIVIDE([Total Criteria];[Total Jobs])
3. The results look like...
I hope this helps
Regards
BILASolution