Forum Discussion
Simple Calculation required
- 7 years ago
Hi shere100
You may create a measure with COUNTX Function.For example:
Measure 2 = COUNTX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Test Result] = "Pass" ), 'Table'[Test Result] ) / COUNTX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Test Result] = "Not Started" ), 'Table'[Test Result] )Regards,
Hi, I am trying to do a count on Test Result column where the total = 'pass' divide by the count of the Test Result column where the total = 'not started' to give the percentage.
Is the above possible to do? or do I need to create an if statement on new column if the data from test Result = 'pass' then place a 1 otherwise place 0, then to do a count on all '0' and '1'. Then create a new meaure and complete the calculation?
If the above method is correct how do I create a new column from the data set from the query? or do I create a new table and then point to the table that has the source data?
- v-cherch-msft7 years agoMicrosoft Employee
Hi shere100
You may create a measure with COUNTX Function.For example:
Measure 2 = COUNTX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Test Result] = "Pass" ), 'Table'[Test Result] ) / COUNTX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Test Result] = "Not Started" ), 'Table'[Test Result] )Regards,
- shere1007 years agoHelper II
Thats absolutely brilliant, that works perfectly.
Final question, if I have a visual from one query can I use that query to add an another visual i.e for the measure I have created? or do I need to create a seperate query and then insert the measure?
- shere1007 years agoHelper II
For the measure that you kindly provided me with, can you please provide an example of an if statement from the column 'Teams' = 'Content Support' to then run the measure calculation.
I need to embed the IF statement where the data is applicable to a specific team only.
- v-cherch-msft7 years agoMicrosoft Employee
Hi shere100
You may create a measure like below.If you need other help,I would suggest you create a new thread on forum so that more community members can see it and provide advice. Please remember to post dummy data and desired result.Kindly mark my answer as a solution for this thread.
Measure = COUNTX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Test Result] = "Pass" && 'Table'[Team] = 'Content Support' ), 'Table'[Test Result] )Regards,
- shere1007 years agoHelper II
Apologies,
Currently the measure is 'Pass' / 'Not Started'.
How would I amend so that it is a'Pass' / 'Not Started + 'Pass' and incorporate in to the measure?
Measure = SUMX ( FILTER ( ALLSELECTED ( Table2 ), Table2[Status] = "Pass" ), Table2[Value] ) / SUMX ( FILTER ( ALLSELECTED ( Table2 ), Table2[Status] = "Not Started" ), Table2[Value] ) - shere1007 years agoHelper II
Hi, can you please advise?
- v-cherch-msft7 years agoMicrosoft Employee
Hi shere100
You could use || .For example:
Table2[Status] = "Not Started"||Table2[Status] = "Pass"
Regards,
- shere1007 years agoHelper II
Many thanks , the calculation is now showing correctly.