Forum Discussion

Allisond's avatar
Allisond
Icon for Advocate II rankAdvocate II
5 years ago

Distinct Count of Measure

Hello, All,

 

I am a rookie with PowerBI and am trying to create a measure that will calculate the distinct count of a result of another measure.   Is there any way to do this?  

 
This is my measure.  It will return only patients with a particular value.  I am wanting to get the distinct patientIDs from this measure, but can't for the life of me figure it out. 
 
Measure 2 = SWITCH(TRUE(), [TestValue] = 1, VALUES(MasterPt[PatientID]))
 
Any help would be so appreciated.

4 Replies

  • Allisond , Try a measure like

    Measure 2 = calculate(distinctcount(MasterPt[PatientID]), filter(MasterPt,MasterPt[TestValue] = 1))

    • Allisond's avatar
      Allisond
      Icon for Advocate II rankAdvocate II

      My [Test Value] is a measure and dax error results.   Is there any way to do this using a measure that references the MasterPt table?

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Allisond 

        In your measure VALUES(MasterPt[PatientID] will return to a table instead of single values so your measure will show error.

        Try

        If([TestValue]=1, Max(MasterPt[PatientID),blank())

        If this reply still couldn't help you solve your problem, please provide me a sample data that may make it easier for me to understabd your data model.

        Or you can share your pbix file with me by your Onedrive for Business.

         

        Best Regards,

        Rico Zhou

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Allisond 

    Could you tell me if your problem has been solved? If it is, kindly Accept the helpul reply as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

     

    Best Regards,

    Rico Zhou