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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
MasterSonic
Helper IV
Helper IV

Check if column contains ONLY specified value

Hi guys,

 

is there a way in power query or dax to check if column (or columns if possible) contain specific value,

 

Eg. I want be sure that coumn "Test" contains only values "OK" for example. So i can put that info nicely on some visual.

 

 

1 ACCEPTED SOLUTION

@MasterSonic 

Then you can try

Count Ok =
SUMX (
VALUES ( 'Table'[Column3] ),
IF ( NOT ( "No" IN CALCULATETABLE ( VALUES ( 'Table'[Column3] ) ) ), 1 )
)

View solution in original post

9 REPLIES 9
tamerj1
Super User
Super User

@MasterSonic 

Please try

Check =
VAR T1 =
VALUES ( 'Table'[Column] )
VAR T2 =
FILTER ( T1, 'Table'[Column] = "Ok" )
RETURN
IF ( COUNTROWS ( T1 ) = COUNTROWS ( T2 ), "Ok", "Check your column" )

As always your solution is superb.

 

Problem is,
it does not do what I want, which obviously is my fault when asking for help.

 

I will paste some EXCEL example. If you could have  a look please.

 

-Imagine that's power bi table.

MasterSonic_0-1663433566302.jpeg

 

- Now I sort on Test1 and looking for OK values, only where OK exists for all records in Column3.
Result I would like to get is  Value 1 as only Alpha qualifies.

MasterSonic_1-1663433662959.jpeg

- Now I sort on Test2 ,
Result is 3 as 3 distinct records from column3 have OKs in column4. 
"Beta" can not be count in as it has NO in one row.

MasterSonic_2-1663433737003.jpeg


Is this is something power bi can do?

 

 

@MasterSonic 

Column 4 can contain only "Yes" or "No", is that correct? If so please try

Count Ok =
SUMX (
VALUES ( 'Table'[Column3] ),
IF ( NOT ( "No" IN CALCULATETABLE ( VALUES ( 'Table'[Column3] ) ) ), 1 )
)

correct

 

@MasterSonic 

Then you can try

Count Ok =
SUMX (
VALUES ( 'Table'[Column3] ),
IF ( NOT ( "No" IN CALCULATETABLE ( VALUES ( 'Table'[Column3] ) ) ), 1 )
)

You are star. It works.

 

For future if you may, what if I would have more values -eg. Yes, No, OK, True.

 

Code would be very different ?

 

@MasterSonic 

Count Ok =
SUMX (
VALUES ( 'Table'[Column3] ),
VAR T1 =
CALCULATETABLE ( VALUES ( 'Table'[Column4] ) )
VAR T2 =
FILTER ( T1, 'Table'[Column4] = "Ok" )
RETURN
IF ( COUNTROWS ( T1 ) = COUNTROWS ( T2 ), 1 )
)

MasterSonic
Helper IV
Helper IV

Thanks for answer.

 

All rows in this particular column should have value OK.

 

Any other values or blank cells would rise some notification like:"please check your column"

tamerj1
Super User
Super User

Hi @MasterSonic 

please provide a clear example that clarifes the meaning of "ONLY"

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.