Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Distinct count of strings

I have a table with a column "opportunity no":TEXT dtype and my DISTINCTCOUNT does not work. I want a measure as Distinct count and I used:  X = DISTINCTCOUNT(business[opportunity_no])   I get th...
  • goncalogeraldes's avatar
    4 years ago

    Hello there Anonymous ! DISTINCTCOUNT() should work even if your column is formatted as text, nevertheless you can try the following and check if it solves your problem:

    X = COUNTROWS(DISTINCT(business[opportunity_no]))  

     Hope this answer solves your problem!
    If you need any additional help please @ me in your reply.
    If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
    Thanks!

    You can also check out my LinkedIn!

    Best regards,
    Gonçalo Geraldes

  • v-jingzhang's avatar
    4 years ago

    Hi Anonymous 

     

    In the table visual, does FY field come from the same 'business' table? Or does it come from a table that is connected to 'business' table and can filter 'business' table? Currently it seems the FY is not able to filter [opportunity_no] column in 'business' table so it doesn't work. 

     

    If they are from two tables and the tables should be disconnected in the model, you can try

    X =
    CALCULATE (
        DISTINCTCOUNT ( business[opportunity_no] ),
        FILTER ( business, business[Year] = MAX ( 'Table'[FY] ) )
    )
    

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.