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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jijods4
Frequent Visitor

Power Bi Custom Filter - How to add interaction with Multiple Categories

I am creating a custom filter in power bi. My basic idea is say, I have two categories "Category and Segment" , which has following values. Category -> Technology,Office Supplies, Furniture. Segment -> Consumer, Corporate, Home Office. and when user want to filter charts based on any of these values he clicks on appropriate buttons.(each value would be a button). How to achieve this?

I have been able to do create a custom filter for one category.When I put two categories filter does not work.

Here is the result with one category -with one categoryThis works exactly with three distinct values. But when we add one more category power bi's Grouping issue comes. Meaning now the grouping is between category and segment and so nine distinct values comes. From power bi perspective its correct but what I am expecting is 6 values only , no grouping between each other.With two Category

How to overcome this?

-- Codes -- getting data.

      let viewModel: ViewModel = {
        dataPoints: []
      };
      if (
        !dv ||
        !dv[0] ||
        !dv[0].categorical ||
        !dv[0].categorical.categories ||
        !dv[0].categorical.categories[0].source
        //   || !dv[0].categorical.values
      )
        return viewModel;
      let view = dv[0].categorical;
      let categories = view.categories[0];
      console.log("Categories:-");
      console.log(categories);
      //   for (let j = 0; j < categories.length; j++) {
      for (let i = 0, len = categories.values.length; i < len; i += 1) {
        viewModel.dataPoints.push({
          category: <string>categories.values[i],
          identity: this.host
            .createSelectionIdBuilder()
            .withCategory(categories, i)
            .createSelectionId()
        });
      }
      //   }

      return viewModel;

-- saying to power bi to slice __this.selectionManager.select(element.identity); where element is each button

What I am expecting is how many ever category we put they don't group each other rather gives back distinct values of each category and for all these a button would be there. On clicking the button it filters the chart.

2 REPLIES 2
Nolock
Resident Rockstar
Resident Rockstar

Hi @jijods4,

have you tried to use a slicer which has a horizontal orientation? You can create as many as you want direct from your fact table or dim tables and it'll filter your fact table as expected.

On the screenshot you can see two slicers and one table which is filtered by both slicers.

 

Capture3.PNG

Thanks for the replay.

 

I have tried it but the problem here is only one caetgory can be accomodated here. If we have 3 categories namly country , state and district then we need 3 slicers basically.

Instead of that what I am looking forward is a search area where we can search contry name, or state name or district name. and then filter happens.

 

Any idea how we can impliment this..?

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.