Forum Discussion

lgs1983's avatar
lgs1983
Icon for Helper I rankHelper I
7 years ago
Solved

Distinct Count with grouping for calculated column

Hi All,

 

I've tried to search the answer to my question but have failed on the numerous paths I've followed so am hoping you are able to help.

 

I have the following columns and what I want to do is create a calculated column to provide a distinct count where for A where, B is different, so:

 

Column1   Mapping       COUNT

A                AA1               2

A                AA1               2

A                AA2               2

B                AA1               2

B                AA2               2

C                AA1               1

C                AA1               1

C                AA1               1

 

So hopefully this makes sense, for A there are two distinct different mappings provided, the same for B. For C though there is only one distinct mapping provided

  • Anonymous's avatar
    Anonymous
    7 years ago

    Try using this for Calculated column:

    Count Column = 
    VAR v_SeriesCnt = CALCULATE
    ( 
        DISTINCTCOUNT( Data[Mapping] ), 
        ALLEXCEPT( Data, Data[Column1] ) 
     )
     RETURN
     v_SeriesCnt

    Thanks.

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Try using this for Calculated column:

    Count Column = 
    VAR v_SeriesCnt = CALCULATE
    ( 
        DISTINCTCOUNT( Data[Mapping] ), 
        ALLEXCEPT( Data, Data[Column1] ) 
     )
     RETURN
     v_SeriesCnt

    Thanks.

    • lgs1983's avatar
      lgs1983
      Icon for Helper I rankHelper I

      Anonymous Wow, that work just as I wanted.

       

      I'm sure it's going to be over my head but what does the VAR v_SeriesCnt do? I'm assuming v_SeriesCnt is the name of the variable.

      • Anonymous's avatar
        Anonymous
        Not applicable

        That's correct. It is just a variable.