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
Anonymous
Not applicable

Remove blank row from calculated table based on filter

I have a table of key-value pairs named Entity and Role.

Entities are companies participating in a transaction.

Roles fall into two groups, buyers and sellers.

For buyers, the entity field always contains the string 'buyer'.

I'm able to create a dimension table for buyers as follows:

dim_buyer =
CALCULATETABLE (
   VALUES( Data[Entity]),
   FILTER( Data,
      CONTAINSSTRING( Data[Role], "buyer")
   )
)

The resulting table includes a blank row that I want to eliminate.

 

In addition, I want to create a companion table that includes sellers. This is defined as distinct values of Data[Entity] where Data[Role] does NOT contain the string "buyer", so that's easy enough:

dim_Seller = 
CALCULATETABLE (
   VALUES(Data[Entity]),
   FILTER( Data,
      NOT(CONTAINSSTRING( Data[Role], "buyer"))
  )
)

I also do not want this table to contain a blank row. 

 

I've tried to filter the result of the CALCULATETABLE to eliminate the blank rows, but I don't have a column name. I tried ADDCOLUMNS in place of VALUES, but then I get the whole table.

 

Any help is very much appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks @FreemanZ 

This works for the dim_buyer table, but I still get a blank row in the dim_seller table.
I double-checked the field values, and there are none with a space or other non-printable character. I also retried replacing blanks with null in Power Query Editor but the blank row remains.

View solution in original post

5 REPLIES 5
FreemanZ
Super User
Super User

hi @Anonymous 

try like:

dim_buyer =
CALCULATETABLE (
   DISTINCT( Data[Entity]),
   FILTER( Data,
      CONTAINSSTRING( Data[Role], "buyer")
   )
)
Anonymous
Not applicable

Thanks @FreemanZ 

This works for the dim_buyer table, but I still get a blank row in the dim_seller table.
I double-checked the field values, and there are none with a space or other non-printable character. I also retried replacing blanks with null in Power Query Editor but the blank row remains.

how about replacing VALUES with DISTINCT as well, like:

dim_Seller = 
CALCULATETABLE (
  DISTINCT(Data[Entity]),
   FILTER( Data,
      NOT(CONTAINSSTRING( Data[Role], "buyer"))
  )
)

 

Anonymous
Not applicable

That's what I did, but I was still getting a blank row.

I think the problem is due to the fact that there are blank or null rows in the table, so if I say "does not contain the string 'buyer'", it will match.


After thinking about the data a bit more, the rows with no buyer or seller are not meaninful. I filtered those out, and now there is no more blank row in the seller table.

 

Thanks very much for your help. I will mark your response as a solution.

Another occasion for unexpected blanks:

if a table is

1) on the one side of a relationship and 

2) does not have all the values in the related colunn from the many side

 

a blank value will be added automatically.

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.