Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Power BI Dax - Distinct Count and Contains String

I am trying to create a measure in Power BI where I am counting the distinct rows of one column if another column contains certain text in a string and keep getting an error.  Any assistance would be helpful.

  • Arul's avatar
    Arul
    3 years ago

    Anonymous ,

    try this measure,

    Count of Task Name = 
    CALCULATE(
        DISTINCTCOUNT('Table'[Task Name]),
        CONTAINSSTRING('Table'[Label],"Weekly"))

    Thanks,

    Arul

  • Anonymous's avatar
    Anonymous
    3 years ago

    Thank you, this was helpful.

4 Replies

  • Arul's avatar
    Arul
    Super User

    Anonymous ,

    Please provide some sample data and the expected output with high level explanation of your requirement.

    Thanks,

    Arul

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello,

     

    Here is some sample data below.  The data is based on tasks activity and I want to count the unique Task Names when Labels column contains "Weekly".  I'm trying to determine the unique tasks names and what their freqnecies are.

     

    Task NameLabel
    Arkansas Children's Hospital - HCP SurveysQuarterly;HCP Surveys
    Crouse Health - Future VisibilityWeekly;Future Visibility
    Internal Delivery - Influenza Vaccination StatusWeekly;Credential Data
    Crouse Health - Future VisibilityWeekly;Future Visibility
    • Arul's avatar
      Arul
      Super User

      Anonymous ,

      try this measure,

      Count of Task Name = 
      CALCULATE(
          DISTINCTCOUNT('Table'[Task Name]),
          CONTAINSSTRING('Table'[Label],"Weekly"))

      Thanks,

      Arul

      • Anonymous's avatar
        Anonymous
        Not applicable

        Thank you, this was helpful.