Forum Discussion

jcastr02's avatar
jcastr02
Icon for Post Prodigy rankPost Prodigy
2 years ago
Solved

Distinct Stores Count of a functionality

I have a list of States with each of the functionalities at each store (A, B, C) If it equals 1 that means the functionality is there, if it has 0 it means it does not. 

 

I'm looking for the count of Distinct States that have these functionalities.  Functionalities A and B are part of a larger process called PHTEST - so looking for the max number between both of those.  Then I just need the distinct count of states for process C.  

 

End result needed - 13 States have Process A or B in it's store & 8 States have Process C in their stores.

 

  PHTEST            
StoreStateABC           
3193FL110           
6341TN010 Row LabelsSum of A  Row LabelsSum of B  Row LabelsSum of C
3912AZ110 AZ4  AZ3  AZ1
3211FL111 FL4  FL7  FL1
3220TX110 IL2  IL2  IL1
3233TX100 IN1  IN1  IN1
4618FL100 KY0  KY1  KY0
11977WV111 LA3  LA3  LA1
4433NV100 MI1  MI1  MI0
4077AZ100 NV2  NV1  NV1
5399FL010 PA1  PA1  PA0
9186AZ110 TN0  TN3  TN0
3365TN010 TX4  TX3  TX0
3555FL010 WI1  WI1  WI1
5382LA110 WV1  WV1  WV1
3822TX110 (blank)   (blank)   (blank) 
5814NV111 Grand Total24  Grand Total28  Grand Total8
4379FL010           
7712KY010 11 Distinct States do not have zero 13 Distinct State do not have zero  8 Distinct States do not have zero
3399LA111           
3406IL111           
3437IN111 PHTEST MAX  13 Distinct States       
3440LA110           
10204FL010           
3473TN010           
9146MI110           
4344AZ111           
7543PA110           
6593TX110           
3539IL110           
5339FL110           
3617WI111           
  • Hi jcastr02 

    Below DAX would work. 

     



    PHTest =
    VAR A_ =
        CALCULATE ( DISTINCTCOUNT ( 'Table'[State] ), 'Table'[A] = 1 )
    VAR B_ =
        CALCULATE ( DISTINCTCOUNT ( 'Table'[State] ), 'Table'[B] = 1 )
    RETURN
        IF ( A_ > B_, A_, B_ )
    

     

    C_ = 
    
    Var C_ = CALCULATE(DISTINCTCOUNT('Table'[State]),'Table'[C]=1)
    
    Return C_

     

    Let me know if you have a different expectation along with some screenshot of expected output and how your table structure is. 

     

    If this post helps, then please consider Accept it as the solution to help the others find it more quickly. Appreciate you kudos!!

    Follow me on LinkedIn!!!

1 Reply

  • NaveenGandhi's avatar
    NaveenGandhi
    Icon for Memorable Member rankMemorable Member

    Hi jcastr02 

    Below DAX would work. 

     



    PHTest =
    VAR A_ =
        CALCULATE ( DISTINCTCOUNT ( 'Table'[State] ), 'Table'[A] = 1 )
    VAR B_ =
        CALCULATE ( DISTINCTCOUNT ( 'Table'[State] ), 'Table'[B] = 1 )
    RETURN
        IF ( A_ > B_, A_, B_ )
    

     

    C_ = 
    
    Var C_ = CALCULATE(DISTINCTCOUNT('Table'[State]),'Table'[C]=1)
    
    Return C_

     

    Let me know if you have a different expectation along with some screenshot of expected output and how your table structure is. 

     

    If this post helps, then please consider Accept it as the solution to help the others find it more quickly. Appreciate you kudos!!

    Follow me on LinkedIn!!!