Title: Filtering
Last modified: July 28, 2020

---

# Filtering

 *  Resolved [jqaush8](https://wordpress.org/support/users/jqaush8/)
 * (@jqaush8)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/filtering-26/)
 * Hey I see in your documentation that the plugin supports filtering. I’m wondering
   where I put the filter code to make it work?

Viewing 1 replies (of 1 total)

 *  [peterbenzoni](https://wordpress.org/support/users/peterbenzoni/)
 * (@peterbenzoni)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/filtering-26/#post-13741700)
 * Hey! Sorry for missing this initially! My team at Atlas maintains this plugin.
 * The short version is that you’ll need add a function to your functions.php to
   do it. (There’s also an easy javascript way to do this if you’re comfortable 
   with that–[see my post on the power bi forums](https://community.powerbi.com/t5/Developer/Power-BI-Embedded-for-WordPress-sending-username-to-PowerBI-side/td-p/1022741))
 * First, you need to find the appropriate hook. This one, for example, when the
   nav menu is created. (You might want page load)
 * For the nav menu case, for example, you can first add this filter to your functions.
   php:
    `add_filter( 'wp_nav_menu_objects', 'append_power_bi_filters', 10, 2 );`
 * Then, you’ll need to create the function the filter references. If the page you
   wanted to apply filters to was, say, example.com/reports/sales and you wanted
   to filter the State table column SalesState to just Illinois, here’s how you’d
   format the function: (inputs surrounded by <carats> — don’t include the carats
   when you use this)
 *     ```
       function append_power_bi_filters( $items, $args ) {
       	foreach ($items as &$item) {
               // check if link begins with '#'
               $urlParts = explode('/',parse_url($item->url, PHP_URL_PATH));
       		if ($urlParts[1] == 'reports' and $urlParts[1] == 'sales' ){
       			$item->url =  $item->url . "?filters=%5B%7B%22%24schema%22%3A%22http%3A%2F%2Fpowerbi.com%2Fproduct%2Fschema%23basic%22%2C%22target%22%3A%7B%22table%22%3A%22<State>%22%2C%22column%22%3A%22<SalesState>%22%7D%2C%22operator%22%3A%22%3D%22%2C%22values%22%3A%5B%22<Illinois>%22%5D%7D%5D";
       		}
               }
       }
       ```
   
 * As you can see, you can set values for the table, column, and value you’re interested
   in.
 * There’s a lot of complexity you can add from here, like changing the referenced
   value or column based on what’s in the URL.
 * Good luck and let me know if you have any questions.
 * Peter
    -  This reply was modified 5 years, 6 months ago by [peterbenzoni](https://wordpress.org/support/users/peterbenzoni/).

Viewing 1 replies (of 1 total)

The topic ‘Filtering’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/embed-power-bi_b2d8bc.svg)
 * [Power BI Embedded for WordPress](https://wordpress.org/plugins/embed-power-bi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/embed-power-bi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/embed-power-bi/)
 * [Active Topics](https://wordpress.org/support/plugin/embed-power-bi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/embed-power-bi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/embed-power-bi/reviews/)

## Tags

 * [filtering](https://wordpress.org/support/topic-tag/filtering/)

 * 1 reply
 * 2 participants
 * Last reply from: [peterbenzoni](https://wordpress.org/support/users/peterbenzoni/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/filtering-26/#post-13741700)
 * Status: resolved