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! Learn more

Reply
Anonymous
Not applicable

Counting rows based on the unique State

Hi All,

I am facing issue in creating a measure. I am using Live connection (SSAS cube ) and my table structure is as follows, 

 

I need to count the distinct number of "Objects" which has only State 2 from the table structured as below.

Note : Objects which has both  States ( State 1 & State 2) should be excluded from the count. 

 

ObjectsState
Obj1State1
Obj1State2
Obj2State2
Obj3State1
Obj3State1
Obj3State2

 

The count should return "1" as Obj2 is the only value containing only State2. 

Kindly help me getting the requested calcuation in measure. 

 

Any help would be appreciated. 

Thanks in Advance.

Kindly help - @amitchandak @parry2k @Cmcmahan 

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

HI @Anonymous ,

 

You can try this

 

 

Measure 6 = 
var a = CALCULATETABLE(VALUES('Table'[Objects]) , 'Table'[State] = "State1")
var b = CALCULATETABLE(VALUES('Table'[Objects]), 'Table'[State] = "State2")
RETURN
COUNTROWS(EXCEPT(b,a))

 

 

1.jpg

 

 

 

Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
harshnathani
Community Champion
Community Champion

HI @Anonymous ,

 

You can try this

 

 

Measure 6 = 
var a = CALCULATETABLE(VALUES('Table'[Objects]) , 'Table'[State] = "State1")
var b = CALCULATETABLE(VALUES('Table'[Objects]), 'Table'[State] = "State2")
RETURN
COUNTROWS(EXCEPT(b,a))

 

 

1.jpg

 

 

 

Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

Anonymous
Not applicable

Hi @harshnathani 

 

Thanks alot. This solution worked. 

I was trying with select columns including othe filters and was getting some values missed in except. Using calculate tables included that filters with ease.

 

Thanks again. 

Praveen

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.