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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NiugeS
Helper V
Helper V

Help with Query - Countif Valid / Not Valid

Hi,


I have 3 columns.  1st column is a group that consists of people who have a category of valid or not valid.  I am trying to work out how I can make an additional column that will say if each group has atleast 1 valid member.

 

GroupPersonValidGroup Has  Valid Member
Group 1Person 1ValidYes
Group 1Person 2Not ValidYes
Group 2Person 3ValidYes
Group 2Person 4ValidYes
Group 3Person 5Not ValidNo
Group 4Person 6Not ValidNo
Group 5Person 7ValidYes
Group 5Person 8Not ValidYes
Group 6Person 9Not ValidNo

 

I'm not sure what to look for so any guidance greatly appreciated.

Many thanks

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@NiugeS 

Add the following Column to your table:

Valid Member = 

IF(
    CALCULATE(
        COUNTROWS('Table'),
        ALLEXCEPT('Table','Table'[Group]),
        'Table'[Valid] = "Valid"
    ) > 0 ,
    "Yes",
    "No"
)   

 

Fowmy_0-1596907390098.png

 

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

7 REPLIES 7
Greg_Deckler
Community Champion
Community Champion

@NiugeS - You could create a measure like this:

Has Valid Member = 
  VAR __Group = MAX('Table'[Group])
  VAR __Table = FILTER('Table',[Group] = __Group && [Valid] = "Valid")
RETURN
  IF(ISBLANK(__Table),"No","Yes")

As a column the same thing would be:

Has Valid Member = 
  VAR __Group = 'Table'[Group]
  VAR __Table = FILTER('Table',[Group] = __Group && [Valid] = "Valid")
RETURN
  IF(ISBLANK(__Table),"No","Yes")

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Fowmy @Greg_Deckler  Thank you both for taking the time to respond.  It appears I may have needed to provide you with more information.


The table is made up of two sources which has a lot of columns in both.  Is there a way to get a simmilar result without merging the two sources?


Source 1 has Group and person and Source 2 has person and valid.


To avoid any confusion, i've attached a test pbix file.  Is it possible to create a calculated column or measure in this scenario?  Any help appreciated.

 

Test PBIX File 


Thank you

@NiugeS 

The Calculated column I provided should still work, can you check,

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedInplease.

  

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy   Thank you.  I got errors when I first tried but have since modified the calculated column you provided and modified it.  I'm not confident the below is correct but appears to work.  Wasn't sure which table to refer to.

 

Valid Member =

IF(
CALCULATE(
COUNTROWS('Table (2)'),
ALLEXCEPT('Table','Table'[Group]),
'Table (2)'[Valid] = "Valid"
) > 0 ,
"Yes",
"No"
)

Hi @NiugeS 

Please add it to your "Table" table, as tested and analyzed, it shows a correct result and will get a correct result based on a bigger data.

Capture1.JPG

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

@NiugeS 

 

It looks fine, you have relationship between the tables and the results are correct as mentioned. 

can you verify and confirm?

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Fowmy
Super User
Super User

@NiugeS 

Add the following Column to your table:

Valid Member = 

IF(
    CALCULATE(
        COUNTROWS('Table'),
        ALLEXCEPT('Table','Table'[Group]),
        'Table'[Valid] = "Valid"
    ) > 0 ,
    "Yes",
    "No"
)   

 

Fowmy_0-1596907390098.png

 

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.