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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
gustalem
Helper I
Helper I

Special distinctcount

Hi everybody! 

I have these three tables: VR connected with Articles by Codigo, and VR with Clientes by CodCliente.

 

gustalem_0-1625073788070.png

 

gustalem_1-1625063745955.png

gustalem_1-1625073816863.png

 

I want to count how many brands has each "CodClient", but it must have a postive sell. I tried to do it with a new table using:

 

CountBrands = summarize(VR,VR[CodCliente],Calendario[Year],Calendario[Month],"Cant marcas",DISTINCTCOUNT(Articles[Brand]),"Total Sales", SUM(Vr[Sales]))

(Calendario is an auxiliary calendar table.)


After that, I do a new measure 

FinalMeasure = Calculate(AVERAGE(CountBrands'Cant Marcas'), CountBrands'Total Sales'>0)

 

And it seems to work, but i would like to do it in a measure, rather than a new table, but im not sure how to do it. 

 

What do you recommend to me? 

 

Thanks you all!

1 REPLY 1
AlexisOlson
Super User
Super User

Compute the total sales for each brand and count how many of those are positive:

 

 

CountBrands =
VAR BrandSummary =
    ADDCOLUMNS (
        VALUES ( Articles[Brand] ),
        "@SumSales", CALCULATE ( SUM ( VR[Sales] ) )
    )
RETURN
    COUNTROWS ( FILTER ( BrandSummary, [@SumSales] > 0 ) )

 

Edit: It might be even simpler to write like this:

CountBrands =
COUNTROWS (
    FILTER ( VALUES ( Articles[Brand] ), CALCULATE ( SUM ( VR[Sales] ) ) > 0 )
)

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.