title: How to get a count of Distinct Dimension values in an SSAS MDX Query
body: <p>I am trying to write an MDX query to return some information about survey questions.  I want Average response and total responses in my results.  I have two types of questions.  One type of question has a single response.  Another type of question can have multiple responses (Pick all that apply).  Each question is tied to a question ID and a respondent ID.  The following query works (somewhat)</p>
  
  <pre><code>Select NON EMPTY 
    {
      [Measures].[Average Response], [Measures].[Total Count]
    } ON 0
  ,   NON EMPTY 
    {
      ([Question].[Question ID].[Question ID].ALLMEMBERS)
    } ON 1
  From [Cube]
  </code></pre>
  
  <p>Average Response is a combination from both single responses and multiple responses (two different fact tables).  The total count is also a combination of the two tables.  The problem is that for single response questions, I can just count the number of respondents.  For multi response questions that falls down as I can have way more responses than I do people taking the survey.  I really want to know how many people provided an answer.  To do this, I think I need the distinct count of respondent IDs.  So I tried changing my first axis to this.</p>
  
  <pre><code>[Measures].[Average Response], [Measures].[Total Count], DISTINCTCOUNT([Respondent].[Respondent ID])
  </code></pre>
  
  <p>Well, that doesn't work and I really didn't expect it to.  I got <strong><em>"The  function expects a tuple set expression for the 3 argument. A string or numeric expression was used."</em></strong>  which is rapidly becoming my favorite SSAS error message.  I am still green at this and I guess I am still thinking SQL.  How can I get an average of the responses and a count of the distinct Dimension values in the same query.  BTW, my query does have a slicer and I could provide that if needed but I don't think it relevant as I get the same problems with or without the slicer.</p>