Forum Discussion

yishenhui's avatar
yishenhui
Icon for Helper II rankHelper II
3 years ago
Solved

distinctcount and countx

Hi,    I'd like to have a dax like distinctcount and countx. discount a table/column with filter.    sample table as below left, I have created a measure m1  (m1 = DISTINCTCOUNT(table1[c1])) and ...
  • Greg_Deckler's avatar
    3 years ago

    yishenhui Try:

    m2 = COUNTROWS( DISTINCT( SELECTCOLUMNS( ALL('table1'), "c1", [c1] ) ) )
  • Greg_Deckler's avatar
    Greg_Deckler
    3 years ago

    yishenhui Try:

    m2 = 
      VAR __c3Table = SELECTECOLUMNS( 'table1', "c3", [c3] )
      VAR __Result = 
        COUNTROWS( 
          DISTINCT( 
            SELECTCOLUMNS( 
              FILTER( ALL('table1'), [c3] IN __c3Table ),
              "c1", [c1] 
            ) 
          ) 
        )
    RETURN
      __Result