Forum Discussion

unnijoy's avatar
unnijoy
Post Prodigy
4 years ago
Solved

Sum based on filter

I have a survay data. I need to find the positive %. So in the Positive column we will be counting the total 1. and that count should be divided by total distinct dount of ID. and for 2021 i have to use the FILTER

now the formula is Positive%= calculate(count (Positive)/distinct count(ID),filter (Year =2021).

 

Now the ussue is that if ant of the employee if his positive is coming as 0 then their ID is not counting. I need the distinct count of all ID irresoective of Positive 1 0r 0. how can i do that. below is the sample.

IDNameAttriPositiveNegativeyear
12JamesHelath112021
12JamesPay022021
12JamesTransport112021
13RexHelath022021
13RexPay112021
13RexTransport022021
14SamHelath012021
14SamPay022021
14SamTransport032021
12JamesHelath012020
12JamesPay022020
12JamesTransport012020
13RexHelath022020
13RexPay112020
13RexTransport022020
14SamHelath012020
14SamPay022020
14SamTransport032020

 

 

  • Measure =
      VAR __Table = FILTER('Table',[year]=2021)
      VAR __Denominator = COUNTROWS(DISTINCT(SELECTCOLUMNS(__Table,"ID",[ID])))
      VAR __Numerator = COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER(__Table,[Positive]=1),"ID",[ID])))
    RETURN
      DIVIDE(__Numerator,__Denominator,0)

    unnijoy Try:

     

4 Replies

    • unnijoy's avatar
      unnijoy
      Post Prodigy

      hi Greg_Deckler ,

       

      thanks for the qucik reply. can i need the filter in over all. Like  = count (positive)/dist(ID),filter 2021. How can i achive this

      • unnijoy's avatar
        unnijoy
        Post Prodigy

        hi Greg_Deckler ,  as per the above table the expected result is as follows.

        positive = 2

        total dist count of id = 3. as u can see that the for the third guy positive is coming as 0 but still we need to count him.

         

        Positive % = 2/3= 67 %