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

Is it possible to count the result of a measure?

Hi,

 

I was wondering if there was possible to count the result of a measure?

 

I have one fact table that contains:

ID_1 | ID_2

123   123

456   456

789   987

654   321

 

As you can see some of the ID 1 and ID 2 are the same, and some are diffrent.

I then have a measure like this:
measure =
VAR ID1 = SUM ( 'Table'[ID_1] )
VAR ID2 = SUM ( 'Table'[ID_2] )
VAR Result = IF ( ID1 <> ID2; 1; 0 )
RETURN
Result

Now I want to count or sum how many has 1 and how many has 0.

I know I can make a calculated column in DAX and then use COUNTROWS, but I was wondering if its possible to solve this with a measure?

Let me know if you need more information or if something is unclear.

 

Thanks,

Marius

1 ACCEPTED SOLUTION
v-danhe-msft
Employee
Employee

Hi @Anonymous,

Based on my test, you could refer to below measures:

sum equals to 0 = COUNTROWS(FILTER('Table','Table'[measure]=0))
sum equals to 1 = COUNTROWS(FILTER('Table','Table'[measure]=1))

Result:

1.PNG

 

Regards,

Daniel He

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-danhe-msft
Employee
Employee

Hi @Anonymous,

Based on my test, you could refer to below measures:

sum equals to 0 = COUNTROWS(FILTER('Table','Table'[measure]=0))
sum equals to 1 = COUNTROWS(FILTER('Table','Table'[measure]=1))

Result:

1.PNG

 

Regards,

Daniel He

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Should be able to do something along the lines of:

 

Measure 2 = 
SUMX(SUMMARIZE('Table',[ID_1],"__Measure",[measure]),[__Measure])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.