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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ricardo_cvo
Helper I
Helper I

Using multiple AND conditions along with the filtered

Good evening everyone,

 

I am using Power BI to run a query in CRM 365, I am using the $ filtered parameter to bring the data of a certain company, however I would like to add to this same filter more companies, using the AND condition this is possible?

 

Thank you

1 ACCEPTED SOLUTION

@ricardo_cvo

A draft demo would like below. This demo would embed a report and apply a filter. It would require some javascript skill.

<html>

 <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/jquery/dist/jquery.js"></script>  
 <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/powerbi-client/dist/powerbi.js"></script>
 
<script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/es6-promise/es6-promise.js"></script>
<script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/fetch/fetch.js"></script>
     

<script type="text/javascript">
window.onload = function () {
 
var embedConfiguration = {
    type: 'report',
    accessToken: 'a valid token',
    id: '734503cf-xxxx-xxxx-xxxx-791d62c154ad',
    embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed?reportId=734503cf-xxxx-xxxx-xxxx-791d62c154ad' 
}; 

var $reportContainer = $('#reportContainer');
 
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
   

 afilter = {
  $schema: "http://powerbi.com/product/schema#advanced",
  target: {
    table: "tablename",
    column: "columname"
  },
  logicalOperator: "Or",
  conditions: [
    {
      operator: "Contains",
      value: "somevalue1"
    },
    {
      operator: "Contains",
      value: "somevalue2"
    }
  ]
}

report.on('loaded', event => {
                    report.getFilters()
                    .then(filters => {
                        filters.push(afilter);
                        return report.setFilters(filters);
                    })
                })

}
</script>

<div id="reportContainer"></div>

</html>

 

View solution in original post

3 REPLIES 3
Eric_Zhang
Microsoft Employee
Microsoft Employee

@ricardo_cvo

If you're talking about appending filter parameter to the embedded url, AFAIK, this approach doesn't support more than one parameter. To implement "and" or "or" filters, you can use the Power BI javascript API to  Construct Filters.

Could you please give more details or some example, power bi has had very little documentation

@ricardo_cvo

A draft demo would like below. This demo would embed a report and apply a filter. It would require some javascript skill.

<html>

 <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/jquery/dist/jquery.js"></script>  
 <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/powerbi-client/dist/powerbi.js"></script>
 
<script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/es6-promise/es6-promise.js"></script>
<script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/fetch/fetch.js"></script>
     

<script type="text/javascript">
window.onload = function () {
 
var embedConfiguration = {
    type: 'report',
    accessToken: 'a valid token',
    id: '734503cf-xxxx-xxxx-xxxx-791d62c154ad',
    embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed?reportId=734503cf-xxxx-xxxx-xxxx-791d62c154ad' 
}; 

var $reportContainer = $('#reportContainer');
 
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
   

 afilter = {
  $schema: "http://powerbi.com/product/schema#advanced",
  target: {
    table: "tablename",
    column: "columname"
  },
  logicalOperator: "Or",
  conditions: [
    {
      operator: "Contains",
      value: "somevalue1"
    },
    {
      operator: "Contains",
      value: "somevalue2"
    }
  ]
}

report.on('loaded', event => {
                    report.getFilters()
                    .then(filters => {
                        filters.push(afilter);
                        return report.setFilters(filters);
                    })
                })

}
</script>

<div id="reportContainer"></div>

</html>

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.