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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
abhi123
Frequent Visitor

embed filter issue

 

Hello,

 

I am finding difficulty in applying the filter through embed javascript api.

 

I have two companies, i.e. 'abc' and 'xyz', I want to apply filter on companyname with 'abc'.

 

I tried below code but it does not apply filter, can anybody help !!!

 

Thanks in advance........

 

          var filterTypeTarget={};
	  var operatorAndValues={};
	  
	  filterTypeTarget.table = 'companytable';
	  filterTypeTarget.column = 'ComapnyName';
	  
	  operatorAndValues.type='basic';
	  operatorAndValues.operator = 'In';
	  operatorAndValues.values = ['abc','xyz'];
	  
	  values = ['abc'];
	  
	  
	  $(function () {
	  
		 var models = window['powerbi-client'].models;
		 var defaultFilter = new models.BasicFilter(filterTypeTarget, operatorAndValues, values);
		  
		  console.log(defaultFilter.toJSON());
		  
		  var report;
		  var embedConfiguration = {
			type: 'report',
			filter: defaultFilter.toJSON(),
			.
			.
			.
			.
			embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed'
	};
	
		var $reportContainer = $('#reportContainer');
		report = powerbi.embed($reportContainer.get(0), embedConfiguration);
         })

 

 

 

10 REPLIES 10
KumarDarmesh
Helper IV
Helper IV

Is this the Power BI javascript api?

Yes it is..........

Sunkari
Responsive Resident
Responsive Resident

@abhi123: Is Javascript api works with Rest API? 

We have integrated our reports in an external application using Rest API(Not Power BI Embedded azure) so we want to customize integration process using Javascript API.

Hi Sunkari

 

I have used Azure powerbi embedded.

 

Can u please tell me the process of extrenal web api for the same(Without Azure)?.........

 

Thanks.

Abhi

Sunkari
Responsive Resident
Responsive Resident

@abhi123: Please go through the following link so that you will get some context about  POWER BI Rest API

https://msdn.microsoft.com/en-us/library/dn877544.aspx

Note: Power BI rest API only supports single filter with single value.

 

Hi @Sunkari

 

Thank you so much for the same will go threw with that and will let you know.

 

Thanks 

Abhi.

hi  @Sunkari

 

Can you please provide one running demo on powerbi javascript api if possible?......really stuck on this.....!!

 

If you can then please.

 

Thanks 

Abhi.

Sunkari
Responsive Resident
Responsive Resident

@abhi123: Sorry Man. I don't have that if found any it. Please share with me 

No issues.

 

Thanks 

Abhi.

In your embedConfiguration, is "filter" or "filters" (with an 's')?

 

Per the documentation, I believe it is filters.

Also, it should be an array  i.e., filters: [ defaultFilter.toJSON() ]

 

Please give it a try and let me know because I too am having issues setting the filters in the embeddedConfiguration. I get the following errors in the console 

https://wabi-us-north-central-redirect.analysis.windows.net/powerbi/metadata/models Failed to load resource: the server responded with a status of 401 (Unauthorized)
Uncaught
  1. Array[3]
    1. 0:Object
      1. message:"filters is invalid. Not meeting type constraint"
      2. __proto__:Object
    2. 1:Object
      1. message:"filters is invalid. Not meeting type constraint"
      2. __proto__:Object
    3. 2:Object
      1. message:"filters property is invalid"
      2. __proto__:Object
    4. length:3
    5. __proto__:Array[0]

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.