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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ysapiyev
Responsive Resident
Responsive Resident

Sync between custom filter and slicer

Hi everyone,

 

I have custom visual which filters date and I also have regular slicer with date with date input and slider.

It looks like this:

 

date dd.png

 

In left I have custom filter which selects specific range and on right I have regular slicer. Even though, I set interaction between them, regular slicer doesn't change.

 

How can I make date input values change and slider, by using my custom visual? 

 

Regards,

Yerkhan

9 REPLIES 9
v-chuncz-msft
Community Support
Community Support

@ysapiyev,

 

Take a good look at Adding Selection and Interaction with Other Visuals.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

How do you apply selection/filter in your custom visual?

The slicer doesn't react on any kind of selection if is's applied via SelectionManager.

 

We would recommend to start using Advanced Filter API.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

ysapiyev
Responsive Resident
Responsive Resident

@v-viig,

 

I'm using selection manager. 

 

To use advanced filter API, I should updateOnRangeSelectionChange formula with my own conditions, right? What it will return?

 

Regards,

Yerkhan 

v-viig
Community Champion
Community Champion

You are correct. The updateOnRangeSelectonChange should be modified but it will return nothing as type is void.

The purpose of this function is to generate an IAdvancedFilter and apply it via applyAdvancedFilter.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

ysapiyev
Responsive Resident
Responsive Resident

@v-viig,

 

I've found some code:

const relativeDateFilter: pbi.models.IRelativeDateFilter = {
  $schema: "http://powerbi.com/product/schema#relativeDate",
  target: {
    table: "Sales",
    column: "OrderDate"
  },
  operator: pbi.models.RelativeDateOperators.InLast,
  timeUnitsCount: 30,
  timeUnitType: pbi.models.RelativeDateFilterTimeUnit.Days,
  includeToday: true,
  filterType: pbi.models.FilterType.RelativeDate
};

Can I use it in filter? I want to be able to select last week. month, year.

 

Regards,

Yerkhan.

v-viig
Community Champion
Community Champion

Yes, I think so.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

ysapiyev
Responsive Resident
Responsive Resident

@v-viig,

 

I'm quite confused about usage of Advanced filter. 

 

In updateOnRangeSelectonChange there are several functions, which are located in sampleslicer.ts. Should I copy them to my code? Are they necessary? 

 

I also tried to build filter using powerbi-models but import of powerbi-models failed with error: "import cannot have reference to module". How it can be resolved?

 

Regards,

Yerkhan

ysapiyev
Responsive Resident
Responsive Resident

@v-viig,

 

I understood how to use advanced filter. However, I've faced new issue:

when I don't use date input, everything works fine:

date_1.pngdate_2.png

 

However, when I use date input, it stops changing.

date_3.png

 

How it can be fixed?

 

Regards,

Yerkhan

v-viig
Community Champion
Community Champion

Could you please clarify what data input is? Are you talking about Power BI Slicer?

 

Currently we would recommend to open Chrome Developer Tools and turn on "Pause on exceptions" in the Sources tab.

After that, try to replicate the issue and see if debugger will catch an exception in the code.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.