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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pankajsonkul
Helper I
Helper I

Set custom filter values as 'blank' or null

Hi,

How to set value as blank to custom filter.

Blank.png

Following code which will create custom filter for blank value as null but it throws following error 

"values.0 is invalid. Not meeting type constraint"

 

code

custom visual code

var customFilter={
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: filters[1].target.table,
column: filters[1].target.column
},
operator: filters[1].operator ,
values:[null]
}

Currently we have requirement such that we have allready existing filter in report and we want merge new custom filter in existing filter. Existing filter value is null  for operator 'is not blank' so whenever we apply existing and new custom filter it will throws value invalid error.

 

So which value pass in custom filter so it will display as (Blank) in filter panel?

Thanks in Advance.

 

8 REPLIES 8
dearwicker
Frequent Visitor

You can do this by using an advanced filter with the IsBlank operator:

 

new pbi.models.AdvancedFilter(
{ table, column }, "And", { operator: "IsBlank", value: "" }
).toJSON()

 

The empty string for value shouldn't be necessary (after all, we are just checking if the column is blank, not comparing it with a value. But I get error messages if 'value' is omitted.

 

The "And" operator is only there because of the perculiar way filters are composed: the above snippet is combining a list of operators which happens to only have one item in the list, so it won't actually use the And.

pankajsonkul
Helper I
Helper I

Hi RubenCruz,

 

we have not found  any solution.

 

Thanks & Regards,

Pankaj

Hi, we also need to able to set (Blank) in basic filters. is there any update regarding this?

We have not found any solution

 

v-chuncz-msft
Community Support
Community Support

@pankajsonkul,

 

Simply try string "(Blank)".

values: ["(Blank)"]
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for reply,
It will throws same error
Following date filter,in which we have allready some date filter and 'Blank' filter whenever we read this filter values in code it will display below output
$schema:"http://powerbi.com/product/schema#basic"
operator:"NotIn"
target:"object"
column:"Date"
table:"DateRange"
__proto__:"object"
values:Array(1)
0:null
length:1

now whenever we add new value in this custom filter it will throws exception for null value.

Existing filter screen shot 

Filters.png

This existing filter values in this filter we want push new filter value like'Feb 2017' it will push but due to null value  it will throws error.Actually in filter pane it will display as '(Blank)' but in code this value is null.

So how we can handle this null value.

 

@pankajsonkul,

 

As an alternative, add another AdvancedFilter. You could also leave a comment on GitHub.

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

Thanks for reply,

You have suggest me use advance filter for handling null value but

Actually my implementation is like I have one custom filter which will I want apply to existing filter(not change any existing filter).

So that time whenever I will try following code it will not work

var basicFilter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: table,
column: column
},
operator: 'In',
values: [value]
};

CurrentPage.getFilters().then(function (allTargetFilters) {
allTargetFilters.push(basicFilter);
CurrentPage.setFilters(allTargetFilters);
});

at time of setFilters it will throws error becuase 

In that existing filter there is one basic filter

{
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: table,
column: column
},
operator: 'NotIn',
values: [null]
};  

so due to null value it will throws error,So my question is how to handle this null value such that it will not throws error.

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.