Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
johmedrano
Frequent Visitor

Distinct Count of Categories

Hello,

In Power BI I do have a visualization like this

 

Column from

Date Table

Column from Sales TableColumn from Product TableColumn from Sales TableColumn from Sales Table
DateProductCategoryPartner IDRevenue
JanuaryA1AX2323
JanuaryB1BY24342
JanuaryB1DX343443
JanuaryC1BX3434
JanuaryB1BY34343
FebruaryC1CY3434
FebruaryD3DY343
FebruaryA1AX4234
FebruaryB1BX34343
FebruaryC2CX3434
     

 

And I would like to create a measure "#Average per Active Partner" that returns the average number or Categories sold per ACTIVE Partner. ACTIVE Partner =  Revenue >0


Date# Average per Active Partner
January1.5
February2.5

 

Could you kindly advise on the DAX formula to use in this case ?

 

Thanks a lot for your patience and support.

2 ACCEPTED SOLUTIONS
Yggdrasill
Responsive Resident
Responsive Resident

Try this measure


 

#ActivePartners = 
VAR _countPartnerID = DISTINCTCOUNT( SalesTable[Partner ID] )
VAR _countCategory =  DISTINCTCOUNT( SalesTable[Category] )  
RETURN
   CALCULATE( 
       DIVIDE( _countCategory ; _countPartnerID ) ; FILTER( SalesTable ; SalesTable[Revenue] > 0 )    
   )

 

measure.PNG

View solution in original post

Vvelarde
Community Champion
Community Champion

@johmedrano

 

Hi, try with this measure:

 

Average per Partner =
VAR DistinctCategories =
    CALCULATE (
        DISTINCTCOUNT ( 'Product Table'[Category] );
        FILTER ( SalesTable; SalesTable[Revenue] > 0 )
    )
VAR ActivePartners =
    CALCULATE (
        DISTINCTCOUNT ( SalesTable[Partner ID] );
        FILTER ( SalesTable; SalesTable[Revenue] > 0 )
    )
RETURN
    DIVIDE ( DistinctCategories; ActivePartners )

Regards

 

Victor

Lima - Peru

 

 




Lima - Peru

View solution in original post

3 REPLIES 3
Vvelarde
Community Champion
Community Champion

@johmedrano

 

Hi, try with this measure:

 

Average per Partner =
VAR DistinctCategories =
    CALCULATE (
        DISTINCTCOUNT ( 'Product Table'[Category] );
        FILTER ( SalesTable; SalesTable[Revenue] > 0 )
    )
VAR ActivePartners =
    CALCULATE (
        DISTINCTCOUNT ( SalesTable[Partner ID] );
        FILTER ( SalesTable; SalesTable[Revenue] > 0 )
    )
RETURN
    DIVIDE ( DistinctCategories; ActivePartners )

Regards

 

Victor

Lima - Peru

 

 




Lima - Peru

@Vvelarde: My thinking exactly ... lol

Yggdrasill
Responsive Resident
Responsive Resident

Try this measure


 

#ActivePartners = 
VAR _countPartnerID = DISTINCTCOUNT( SalesTable[Partner ID] )
VAR _countCategory =  DISTINCTCOUNT( SalesTable[Category] )  
RETURN
   CALCULATE( 
       DIVIDE( _countCategory ; _countPartnerID ) ; FILTER( SalesTable ; SalesTable[Revenue] > 0 )    
   )

 

measure.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.