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