Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Calculate and filter not working

Hello All, 

 

I am running some survey stats and have a simple aggregate measure. I am looking to calculate the number of codes in the dataset which have less than 70% respondent agreement. I am using the following dax: 

 

% Agree <70 = CALCULATE(COUNT(Sheet1[course_code]),FILTER(Sheet1,[11 % Agree Col]<.7))

 

Its not producing the right answers, the dataset is set up that there may be multiple records for each code, one record for each respondent. 

 

What am I doing wrong?

  • Anonymous

     

    In that case.....Try Replacing allselected with VALUES

     

    % Agree <70 =
    COUNTROWS ( FILTER ( VALUES ( Sheet1[course_code] ), [11 % Agree Col] < .7 ) )

11 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hey Anonymous

     

    Maybe you can try this:

     

    % Agree <70 = CALCULATE(COUNT(Sheet1[course_code]),FILTER(ALLSELECTED(Sheet1),[11 % Agree Col]<.7))

    The only difference is that I added ALLSELECTED to your filter. Might want to try ALL if that doesn't work. Let me know if this helps.

     

    -Parker

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Parker neither worked :(

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        How are you displaying this measure? A card visual?

         

        Also, are you just trying to get the distinct number of codes? In which case you might want to use the DISTINCTCOUNT function