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
Dzvene
New Member

Filters target doesn't match slicer target (Hierarchy Slicer, Embedded)

We are trying to save the state of the slicers and apply them.

We get the state using getSlicerState () and, on the onLoad event, we try to apply them with .setSlicerState(),

 

When we try to apply the saved state, we get an error:

Снимок экрана 2020-03-27 в 10.02.46.png

 

The state that we save and try to apply:

Снимок экрана 2020-03-27 в 10.06.43.png

Why we can't use the saved state for the same slicer аnd what do we need to do to apply them?

 

For other slicers, it works correctly, the problem only with Hierarchy Slicer.

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @Dzvene ,

Please try to provide a target of type IFilterHierarchyTarget. example:

const basicFilter = {
  $schema: "http://powerbi.com/product/schema#basic",
  target: {
    table: "Store",
    hierarchy: "Country",
    hierarchyLevel: "Code"
  },
  operator: "In",
  values: [456, 943],
  filterType: pbi.models.FilterType.BasicFilter
};

visual.setSlicerState({
    filters: [basicFilter]
});

Reference:

https://github.com/Microsoft/PowerBI-JavaScript/wiki/Slicers

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
shahabazshafisk
Regular Visitor

I tried the same format for the filter and I am still getting the same error.

const filters = {
    "target": { table: "Date", hierarchy: Date Hierarchy, "hierarchyLevel": "Date" },
    "filterType": models.FilterType.RelativeDate,
    "operator": models.RelativeDateOperators.InLast,
    "timeUnitsCount": 10,
    "timeUnitType": models.RelativeDateFilterTimeUnit.Days,
    "includeToday": true
};


The the SlicerState I got upon calling getSlicerState Method

{
"filters": [
{
"$schema": "http://powerbi.com/product/schema#relativeDate",
"target": {
"table": "date",
"hierarchy": "Date Hierarchy",
"hierarchyLevel": "Date"
},
"filterType": 4,
"operator": 0,
"timeUnitsCount": 6,
"timeUnitType": 4,
"includeToday": true
}
],
"targets": [
{
"table": "date",
"column": "Date"
}
]
}


v-xuding-msft
Community Support
Community Support

Hi @Dzvene ,

Please try to provide a target of type IFilterHierarchyTarget. example:

const basicFilter = {
  $schema: "http://powerbi.com/product/schema#basic",
  target: {
    table: "Store",
    hierarchy: "Country",
    hierarchyLevel: "Code"
  },
  operator: "In",
  values: [456, 943],
  filterType: pbi.models.FilterType.BasicFilter
};

visual.setSlicerState({
    filters: [basicFilter]
});

Reference:

https://github.com/Microsoft/PowerBI-JavaScript/wiki/Slicers

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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.

Top Kudoed Authors