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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lopa30
Frequent Visitor

Count of blanks showing up as 1 but want 0

Hello,

 

I am new to Power BI and was having some trouble using measures.

 

I have a table with multiple columns including:

 

Sl.NoDateNew Item ID
1March 2023A123
2March 2023A124
3April 2023 
4May 2023A226

 

I want to create a line graph with the number of new items per month but when I use the count of new items, it shows that there is an item for April 2023 even though there shouldn't be (1 instead of 0).

 

I tried creating a measure:

IF(ISBLANK(Table1['New Item ID']), 0, DISTINCTCOUNT(Table1['New Item ID']))

 

However, I was getting an error: A single value for column 'New Item ID' in table 'Table 1' cannot be determined. This can happen when a measure formula refers to a column that only contains many values without specificying an aggregration such as min, max, count or sum to get a single result.

 

I also tried the measure: DISTINCTCOUNT(Table1['New Item ID']) + 0 and that shows 1 for blank values (like April 2023) as well.

 

Thank you

11 REPLIES 11
johnt75
Super User
Super User

You can use DISTINCTCOUNTNOBLANK(Table1['New Item ID']) + 0 

Thank you. I tried that as well and it is still showing as 1.

Are you sure that the value is actually blank, and doesn't have a space character or something in it?

 tried checking it using Python (pandas) and it is a null value there. Is there a way to check to check on Power BI as well? 

If you go into data view you can click the down arrow in the column header, that will allow you to filter by value, including blank.

Thank you! It seems like it is not blank. Is there a way of checking what exactly is included in the "blanks" as in how many empty spaces? The excel file has blank values so I'm not sure how it changed in power BI.

 

Alternatively, all of the IDs start with A so I thought I could use the measure:

if((containsstring(selectedvalue(table1['New Item ID']), "A")), DISTINCTCOUNT(Table1['New Item ID']), 0) but now I'm getting everything as 0. What am I doing wrong?

 

Thank you so much!

 

You could add a couple of new calculated columns to your table,

Item length = LEN( 'table1'[New Item ID])

New string = "'" & 'table1'[New Item ID] & "'"

that will show you the length of the string and will wrap the string in single quotes so it is easier to see what the value is.

I tried this as well and it says that the length of the "blanks" are 0.

It might be worth looking in Power Query, see if you can replace the empty string with null. In the Replace Values dialog, leave the Value to Find field empty and type null into the Replace With.

Thank you so much for all the help! I'm not sure if it's the cleanest solution but it works.

 

I ended up creating a calculated column using:

New Item ID Clean = IF(CONTAINSSTRING(Table1[New Item ID], "A*")), Table1[New Item ID], BLANK()

 

and then used the measure DISTINCTCOUNTNOBLANK(Table1['New Item ID Clean']) + 0 

lopa30
Frequent Visitor

But unlike other columns which clearly say (Blank) when filtering this just is white. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors