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
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
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.