Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
user35131
Helper III
Helper III

How to Create measure count from Group ID if it has at least one appearance of a specific value?

 

IDCol 2
1N

1

N
1Y
2N
2N
3Y
3Y
3Y
4N
4N
4Y
4N
5N

 

Note that Group ID 1 has at least one "Y" so count 1. Group ID does not have a "Y" so no count. 3 has all "Y" so count 1. 4 has all N but at least one "Y" so Count 1. 5 has no "Y" so no count. 

 

In total my measure should provide me a count of 3. 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @user35131 ,

Here are the steps you can follow:

1. Create measure.

Count Group ID =
var _table=SUMMARIZE('Table','Table'[ID],"1",CALCULATE(COUNT('Table'[Col 2]),FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Col 2]="Y")))
return
COUNTX(FILTER(_table,[1]>=1),[ID])

2. Result:

vyangliumsft_0-1644473451079.png

 

Best Regards,

Liu Yang

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

7 REPLIES 7
v-yangliu-msft
Community Support
Community Support

Hi  @user35131 ,

Here are the steps you can follow:

1. Create measure.

Count Group ID =
var _table=SUMMARIZE('Table','Table'[ID],"1",CALCULATE(COUNT('Table'[Col 2]),FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Col 2]="Y")))
return
COUNTX(FILTER(_table,[1]>=1),[ID])

2. Result:

vyangliumsft_0-1644473451079.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

user35131
Helper III
Helper III

I'm also getting the unique count without the condition if it has more than one distinct value.

TheoC
Super User
Super User

Hi @user35131 

 

You can use the following measure to achieve the output you want.

 

 

Measure = 

VAR _1 = COUNTROWS ( FILTER ( DISTINCT ('Table'[ID] ) , DISTINCTCOUNT ('Table'[Col 2] ) > 1 ) )

RETURN 

_1

 

Hope this helps and all the best!

Theo 🙂

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Even though it doesn't reference the "Y" in the code it will work? 

@user35131 it returns anything with more than one distinct value. Give it a go and let me know how it goes 🙂

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

I'm getting the unique count without the condition that there is at least one distinct count.

@user35131 Did you add Client ID and then the measure to a table?

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.