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
MasterSonic
Helper IV
Helper IV

Sum unique value in column per category

Hello,

 

having this table :
Code Group Processing Status

101Jeans1Ordered
101Jeans1Ordered
102Jeans1In Delivery
103Shirt3In Delivery
104Shirt3In Delivery
105Shirt3In Delivery
106Shirt3Sold
107Shoe66Sold



I have this measurment :

 

 

Status count per Code = var _status = SELECTEDVALUE('Table'[Status])
var _processing =SUMX(SUMMARIZE('Table','Table'[Group],'Table'[Processing]),'Table'[Processing])
var _t=DISTINCT(SELECTCOLUMNS( FILTER( ALLSELECTED('Table') ,'Table'[Status]=_status) , "Code" , [Code]))
return
IF(_status ="Sold" , _processing , COUNTROWS(_t))

 

 

_processing show  70 on it's own- correct,
but with other values just 69, how to get value 70 here?
MasterSonic_0-1669455186087.png

 



 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @MasterSonic 

please try

Status count per Code =
VAR _status =
SELECTEDVALUE ( 'Table'[Status] )
VAR _processing =
SUMX (
SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[Group], 'Table'[Processing] ),
'Table'[Processing]
)
VAR _t =
DISTINCT (
SELECTCOLUMNS (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Status] = _status ),
"Code", [Code]
)
)
RETURN
IF ( _status = "Sold", _processing, COUNTROWS ( _t ) )

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @MasterSonic 

please try

Status count per Code =
VAR _status =
SELECTEDVALUE ( 'Table'[Status] )
VAR _processing =
SUMX (
SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[Group], 'Table'[Processing] ),
'Table'[Processing]
)
VAR _t =
DISTINCT (
SELECTCOLUMNS (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Status] = _status ),
"Code", [Code]
)
)
RETURN
IF ( _status = "Sold", _processing, COUNTROWS ( _t ) )

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.