Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Distinct COuntx

Hi Team,

I havae a dataset where i need to get distinct count of projectid where filter condition on cloumn Met/Not Met = "Met"

However this dax is not working as i need unique projectid and i am getting entire count 

Kindly help to fix the issue 

 

Project IDMet/not met
1289-03Not Met
1289-04Not Met
1790-01Not Met
1898-01Not Met
2455-01Not Met
2966-01Not Met
3319-01Not Met
3890-01Not Met
4690-01Not Met
4721-01Not Met
4783-03Not Met
5385-01Not Met
5571-01Not Met
5710-01Not Met
5850-01Not Met
5952-01Not Met
6193-01Not Met
1287-05Not Met
1293-12Not Met
3494-02Not Met
3881-02Not Met
5450-01Not Met
5929-01Not Met
6008-01Not Met
6211-01Not Met
1244-04Not Met
1258-10Not Met
1293-09Not Met
1921-01Not Met
4320-01Not Met
5800-01Not Met
5864-01Not Met
6031-08Not Met
6259-01Not Met
1258-11Not Met
1869-01Not Met
5450-06Not Met
5713-03Not Met
6548-01Not Met
6826-01Not Met
1250-08Not Met
1258-06Not Met
3101-01Not Met
6618-01Not Met
6620-01Not Met
1267-06Not Met
3319-02Not Met
4534-01Not Met
5472-01Not Met
5626-01Not Met
5712-01Not Met
6546-01Not Met
7030-01Not Met
7311-01Not Met
7469-01Not Met
1290-05Not Met
6748-01Not Met
7472-01Not Met
6985-01Not Met
7326-01Not Met
7380-01Not Met
7561-01Not Met
7696-01Not Met
1869-04Not Met
7748-05Not Met
8080-01Not Met
8524-01Not Met
8535-01Not Met
7250-05Not Met
5772-07Not Met
8262-01Not Met
8539-01Not Met
9211-02Not Met
8751-01Not Met
10162-01Not Met
9757-04Not Met
9778-01Not Met
9757-01Not Met
4768-01Not Met
10352-04Not Met
10890-01Not Met
11365-01Not Met
10823-01Not Met
10934-01Not Met
9542-04Not Met
1200-01Met
1203-01Met
1293-07Met
1898-02Met
2034-12Met
2047-01Met
2049-01Met
2065-01Met
3347-01Met
3550-03Met
4219-01Met
4442-03Met
4658-01Met
4960-01Met
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    Create a new table with the following dax expression.

     

    NewTable = 
    SUMMARIZE (
        'Table',
        'Table'[Project ID],
        "Met", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Met/not met] = "Met" ),
        "Not Met", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Met/not met] = "Not Met" )
    )

     

    Then create two new columns based on this.

     

    Grand Total = 'NewTable'[Met]+'NewTable'[Not Met]
    Condition = IF('NewTable'[Met]='NewTable'[Grand Total],1,0)

     

    Finally create a measure.

    count 1 = CALCULATE(COUNTROWS('NewTable'),FILTER('NewTable','NewTable'[Condition]=1))

     

    specific value = 
    VAR _condition_all = CALCULATE(COUNTROWS('NewTable'))
    RETURN
    [count 1]/_condition_all

     

    The result should be like this.

    Attach the pbix file for reference. Hope it helps.

     

    Best Regards,
    Community Support Team_Gao


    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

3 Replies

  • Anonymous , Try like

     

    calculate(distinctCOUNT(Table[ProjectId]), filter(Table, Table[ Met/Not Met] = "Met"))

  • Anonymous's avatar
    Anonymous
    Not applicable

    Actually i tried all those steps and it is not matching with the requirement.

    Let me rephrase it one more time

    Consider below table 

    Project IDMetNot MetGrand TotalCondition = If (Met = Grand Total), 1,0)
    10030-012 21
    10077-035 51
    10093-028 81
    10098-019 91
    1010-0142 421
    10119-0113 131
    10142-015 51
    10162-015270
    10310-027 71
    10331-048 81
    10352-042240
    10376-0112 121
    10379-025 51

    Now i want to count how many 1 and total sum i.e, 11/13

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Create a new table with the following dax expression.

     

    NewTable = 
    SUMMARIZE (
        'Table',
        'Table'[Project ID],
        "Met", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Met/not met] = "Met" ),
        "Not Met", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Met/not met] = "Not Met" )
    )

     

    Then create two new columns based on this.

     

    Grand Total = 'NewTable'[Met]+'NewTable'[Not Met]
    Condition = IF('NewTable'[Met]='NewTable'[Grand Total],1,0)

     

    Finally create a measure.

    count 1 = CALCULATE(COUNTROWS('NewTable'),FILTER('NewTable','NewTable'[Condition]=1))

     

    specific value = 
    VAR _condition_all = CALCULATE(COUNTROWS('NewTable'))
    RETURN
    [count 1]/_condition_all

     

    The result should be like this.

    Attach the pbix file for reference. Hope it helps.

     

    Best Regards,
    Community Support Team_Gao


    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!