Forum Discussion

Applicable88's avatar
Applicable88
Impactful Individual
5 years ago
Solved

Countrows in a summarize argument

Hello,

I'm very confused about a grouped table with an aggregated function. I will show whats happening in DaxEditor. My table:

SerialnumberStatus
BF33333K
BF33334K
BF33335K
BF33336K
BF33337K
BF33338V
BF33339V
BF33340V
BF33341V
BF33342V

 

After summarizing I get the following table:

summarize(Tabelle2,[Status],"Name",COUNTROWS(Tabelle2))

As seen here are two rows as a return, but why I get the values of 20 after wraping it into a sumx-function?:

SUMX(summarize(Tabelle2,[Status],"Name",DISTINCTCOUNT(Tabelle2[Status])),countrows(Tabelle2))

Shouldn't the expected outcome be 10?

 

Best.

  • amitchandak's avatar
    amitchandak
    5 years ago

    Applicable88 , this should give you 10

     

    SUMX(summarize(Tabelle2,[Status],"_cnt",DISTINCTCOUNT(Tabelle2[Status])),[_cnt])

     

    20, I am not sure, may be

     

    SUMX(summarize(Tabelle2,[Status],"_cnt",COUNT(Tabelle2[Status])),[_cnt])

3 Replies

  • Applicable88 , Are you only counting status

     

    try like

    countrows(summarize(Tabelle2,[Status],"Name",DISTINCTCOUNT(Tabelle2[Status])))

    • Applicable88's avatar
      Applicable88
      Impactful Individual

      Hi amitchandak ,

      with your function I get 2, which also make sense. 

      But my question is, why do I get 20? And how to return 5+5=10?

      Since I build the summarize table in the first screenshot, I want to summarize the counts of serialnumbers per row. Which I don't understand why it does not leads to 10 .

      • amitchandak's avatar
        amitchandak
        Super User

        Applicable88 , this should give you 10

         

        SUMX(summarize(Tabelle2,[Status],"_cnt",DISTINCTCOUNT(Tabelle2[Status])),[_cnt])

         

        20, I am not sure, may be

         

        SUMX(summarize(Tabelle2,[Status],"_cnt",COUNT(Tabelle2[Status])),[_cnt])