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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lucmax
Helper II
Helper II

Apply JSON filter with date hierachry not working

Hi all,

 

we are developing our own visual that creates filters based on the json filter (applyJsonFilter). this works great with all dates, but we are having problems with the date hierarchy. We have the following hierarchy in a table named 'Cases' and if I filter on the field 'Year' using a normal slider it will show that it is filtered on the field 'Cases'[Year].

 

Bildschirmfoto 2022-09-22 um 16.36.24.png

 

 

 

 

 

 

Creating a basic filter on exactly this field from within our visual doas not create a filter in the report. The strange thing is, that it will be created in the jsonFilters array of the visualUpdateOptions object.

 

We are creating the filter the following way, of course in our code the values are not static like in th example. But these are the values that will be used in our example which is not working.

 

const target = {
    table: 'Cases',
    column: 'Year',
};

const values = [2018];
            
const basicFilter: IBasicFilter = {
    $schema: 'https://powerbi.com/product/schema#basic',
    filterType: FilterType.Basic,
    operator: 'In',
    target,
    values,
};

this._visualHost.applyJsonFilter([basicFilter], 'general', 'filter', FilterAction.merge);

 

What are we doing wrong? Is there no way to filter on date hierarchies in custom visuals?

 

Best regards,

lucmax

 

 

 

 

1 ACCEPTED SOLUTION
lucmax
Helper II
Helper II

Figured it out, we needed to get the name from the source.entity object within the identityExprs array. Thats the, I  guess technical name, of the date hierarchy table. If we set a filter on this table everything works as expected.

source_entity.png

 

View solution in original post

3 REPLIES 3
lucmax
Helper II
Helper II

Figured it out, we needed to get the name from the source.entity object within the identityExprs array. Thats the, I  guess technical name, of the date hierarchy table. If we set a filter on this table everything works as expected.

source_entity.png

 

v-chenwuz-msft
Community Support
Community Support

Hi @lucmax ,

 

I found an official document, I do not know whether it will be helpful for you.

Add bookmark support for Power BI custom visuals - Power BI | Microsoft Learn

 


Best Regards

Community Support Team _ chenwu zhu

Hi @v-chenwuz-msft ,

thank you for the answer, but I'm afraid that won't help. When we filter at the hierarchy level, we do not have a complete date object, only the individual values.

If I filter on the underlying complete date, everything works as intended. Only the hierarchy causes problems.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.