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
saivina2920
Post Prodigy
Post Prodigy

How do we get count of blank values if more than two column conditions

I am trying to get count of blank values which i used somewhere in SQL. But, the same scenario i am going to use in POWER BI DAX.

 

will it work the below DAX in power bi.

 

=DISTINCTCOUNT(DISTINCT SALE_REF_NUMBER,SALE_PLACE= len(trim(SALE_PLACE)) =0,SALE_RETURN = len(trim(SALE_RETURN))=0,SALE_QTY = len(trim(SALE_QTY)) =0)

1 ACCEPTED SOLUTION

I tried below. but, surprisingly it's working and count is coming perfect. i thing, we can use "" for blank. 

pls. confirm the DAX will work for all the cases.

 

VAR TCOUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]),FILTER(Table, 
Table[EMP_PLACE]="" &&   // "" ==> will it work for blank data
Table[EMP_COUNTRY]="" && // "" ==> will it work for blank data
Table[EMP_REMARKS]=""  // "" ==> will it work for blank data
))
RETURN TCOUNT

 

NOTE

I filtered using manual as you given sample data. it's like below and total count is almost "6".

 

saivina2920_0-1616520347534.png

 

 

View solution in original post

17 REPLIES 17
PhilipTreacy
Super User
Super User

Hi @saivina2920 

To check your column in DAX, create a new column and use the LEN function, for example :

 

Column = LEN([EMP_PLACE])

 

 

lenfx.png

 

If you find that the 'blank' values have a length then this may be just space characters.  You can remove these using the TRIM function in which case you could use this DAX to work out the count you want

 

Blank_Count = 

VAR __EMP_PLACE_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', ISBLANK(TRIM('Table'[EMP_PLACE])=0)))
VAR __EMP_COUNTRY_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', ISBLANK(TRIM('Table'[EMP_COUNTRY])=0)))
VAR __EMP_REMARKS_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', ISBLANK(TRIM('Table'[EMP_REMARKS])=0)))

RETURN

__EMP_PLACE_COUNT + __EMP_COUNTRY_COUNT + __EMP_REMARKS_COUNT

 

 

If none of this works you may have someother non-printing characters in the column, like TAB characters.

To check this, create a column in DAX and use this code

Column1 = UNICODE([EMP_PLACE])

which will give you the numeric code for the character.  If you get to this point let me know what that code number is.

 

If you still haveno success please post some sample data/supply your PBIX to make it easier for me to work out.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @saivina2920 

 

Download sample PBIX file

 

This works with my sampledata in attached file.  If your values really are BLANK then change  LEN('Table'[Column])=0 to ISBLANK('Table'[Column]) in this measure

 

 

Blank_Count = 

VAR __EMP_PLACE_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', LEN('Table'[EMP_PLACE])=0))
VAR __EMP_COUNTRY_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', LEN('Table'[EMP_COUNTRY])=0))
VAR __EMP_REMARKS_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', LEN('Table'[EMP_REMARKS])=0))

RETURN

__EMP_PLACE_COUNT + __EMP_COUNTRY_COUNT + __EMP_REMARKS_COUNT

 

 

blank-count.png

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Sorry for the late response. yours is correct if we calculate and count of every column values

I checked the blank and it's null value only. 

But, i want to apply filter. so that i can get the correct count.

i tried below, but, it's showing error.

 

 

 

VAR TCOUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]),FILTER(Table, 
Table[EMP_PLACE]=LEN(Table[EMP_PLACE])=0 && 
Table[EMP_COUNTRY]=LEN(Table[TN_FROM])=0 && 
Table[EMP_REMARKS]=LEN(Table[TN_TO])=0 
))
RETURN TCOUNT

Will the above work if i used all in one filter

@saivina2920 

Need more info.  What's the error?  The columns in your latest DAX are different to the columns you showed in your image.  What's in them?

Can you supply some data? Really hard to help you without knowing what data you're working with.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


I tried below. but, surprisingly it's working and count is coming perfect. i thing, we can use "" for blank. 

pls. confirm the DAX will work for all the cases.

 

VAR TCOUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]),FILTER(Table, 
Table[EMP_PLACE]="" &&   // "" ==> will it work for blank data
Table[EMP_COUNTRY]="" && // "" ==> will it work for blank data
Table[EMP_REMARKS]=""  // "" ==> will it work for blank data
))
RETURN TCOUNT

 

NOTE

I filtered using manual as you given sample data. it's like below and total count is almost "6".

 

saivina2920_0-1616520347534.png

 

 

Really sorry for the wrong column name.

pls. find the correct column as below with DAX.

 

VAR TCOUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]),FILTER(Table, 
Table[EMP_PLACE]=LEN(Table[EMP_PLACE])=0 && 
Table[EMP_COUNTRY]=LEN(Table[EMP_COUNTRY])=0 && 
Table[EMP_REMARKS]=LEN(Table[EMP_REMARKS])=0 
))

RETURN TCOUNT

 

Error thrown : DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.

if i use below i am getting wrong count.

 

Blank_Count = 

VAR __EMP_PLACE_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', LEN('Table'[EMP_PLACE])=0))
VAR __EMP_COUNTRY_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', LEN('Table'[EMP_COUNTRY])=0))
VAR __EMP_REMARKS_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', LEN('Table'[EMP_REMARKS])=0))


RETURN

__EMP_PLACE_COUNT + __EMP_COUNTRY_COUNT + __EMP_REMARKS_COUNT

 

 

so, i decided to use in filter. Because, my earlier other report was using "&&" conditions.

 

pls. let me know if you need any more details.

I filtered using manual as you given sample data. it's like below and total count is almost "6".

 

saivina2920_0-1616516819716.png

 

You are really great. I chacked length of blank column data. 

 

All the blank column of the length showing as "1" instead of "0".

 

Is it possible to come as "1" for blank values (checkd Text.length)...?

Hi @saivina2920 

If your 'blank' values have length 1 then they aren't really blank of course.  You can check for 'blank' values of length 1 with this measure

Blank_Count = 

VAR __EMP_PLACE_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', LEN('Table'[EMP_PLACE])=1))
VAR __EMP_COUNTRY_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', LEN('Table'[EMP_COUNTRY])=1))
VAR __EMP_REMARKS_COUNT = CALCULATE(DISTINCTCOUNT('Table'[EMP_NO]), FILTER('Table', LEN('Table'[EMP_REMARKS])=1))

RETURN

__EMP_PLACE_COUNT + __EMP_COUNTRY_COUNT + __EMP_REMARKS_COUNT

You mention Text.Length which is a Power Query M function, do you want the solutionin DAX or M?

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


I am just checking blank value length. for that i am checking and creating customized column Text.Length. There only i found Text.Length which contains blank is 1 (i hope some junk value is there.)

because all the data coming from oracle data base.

But, i really want  solution in DAX...

How do i check whether the column is really blank or having some junk values using DAX...?

PhilipTreacy
Super User
Super User

Hi @saivina2920 

Hard to give you an answer without seeing your data.  What column are you looking for blanks in?

You can count the number of blanks in a column like this

CALCULATE(COUNTROWS('Table'), FILTER('Table', ISBLANK('Table'[Column])))

Please provide some sample data.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


DATA IMAGE.PNG

Ashish_Mathur
Super User
Super User

Hi,

Please share some data, define the question in simple English (not an SQL code) and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

pls find image data for your reference.

take count of 3 blank columns (which distinct of EMP_NO (because EMP_NO, it not unique)

DATA IMAGE.PNG

Hi,

One idea would be to replace all blanks with NA using the Query Editor.  Thereafter, right click on the first column and select "Unpivot other columns".  Then drag the Emp_no column to the table visual and write this measure

Measure1 = calculate(countrows(data),data[value]="na")

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

pls. let us know if you need any more details.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.