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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Grouping a List of Values and Counting it as 1, otherwise 0

Hello.  I am fairly new to Power Bi and am struggling with how to do this.  I would like to group a list of values for a customer based on a field in my table.  If the table shows the customer has every value, I would like to show a 1; otherwise show a 0.

 

EX:  Customer ID         Value

             1                     Dog

             1                     Cat

             1                     Bird

             1                     Rabbit

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I found a solution by creating a measure using the Calculate, Count and Filter functions:

 

TestID = IF (CALCULATE(
COUNT(Query2[ID]),
FILTER(
Query2,
Query2[BadgeName] = "Test East" ||
Query2[BadgeName] = "BB" ||
Query2[BadgeName] = "MD" ||
Query2[BadgeName] = "NEP" ||
Query2[BadgeName] = "NJ"
)
) = 5,1,0)

View solution in original post

4 REPLIES 4
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

>>If the table shows the customer has every value, I would like to show a 1; otherwise show a 0.

 

I am not sure what desired result would you want, could you please share your sample data and desired output screenshots for further analysis? You can also upload sample pbix to OneDrive and post the link here. Do mask sensitive data before uploading.

 

Please read this post to get your answer quickly: How to Get Your Question Answered Quickly.

 

Best Regards,

Amy

Anonymous
Not applicable

Here is the column I created:  TestID = IF(([BadgeName]="Test East" && [BadgeName] IN {"Test East","BB","MD","NEP","NJ"}),1,0)

 

Here is the outputcompletedsets.PNGPROBLEM:  1111997 is showing a 1 because it matches 1 of the values in the IN statement.  It should show a 0 because it doesn't match ALL of the values in the IN statement.  How can I fix this?  Thanks!

Anonymous
Not applicable

I found a solution by creating a measure using the Calculate, Count and Filter functions:

 

TestID = IF (CALCULATE(
COUNT(Query2[ID]),
FILTER(
Query2,
Query2[BadgeName] = "Test East" ||
Query2[BadgeName] = "BB" ||
Query2[BadgeName] = "MD" ||
Query2[BadgeName] = "NEP" ||
Query2[BadgeName] = "NJ"
)
) = 5,1,0)

Nathaniel_C
Super User
Super User

Hi @Anonymous 

Here is my table.

 

 

myTable.PNG

Create a measure, place it on a matrix that has the list of customers as follows. The picture has the measure as well. Cust 1 owns all Cust 2 does not.

 

Measure1.PNGThe table is Cust Own

If this solves your issue, please mark this as the solution. Kudos are nice too!

@Nathaniel_C 





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

Proud to be a Super User!




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.