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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
andres777
Advocate III
Advocate III

Power BI Custom Visuals binding to Report Calendar

Hi Dev friends,

I'm writing my first Custom Visual this week in Power BI using the new v3 of "powerbi-visuals-api".

It's a Calendar Datepicker that allows a selection of a single date, defaults to yesterday
and usies a control I purchased from a vendor.

 

I got most things to work and the calendar is showing in the test report (nice),

but I'm on the last step and I need help binding the user selected date to the rest of the data in the report...

so it will filter data using my Calendar table's DATE field. (that I pass as a Grouping argument)


Most of the code I've seen online are for D3 graphs / Charts, and the slicers I found use the old libraries

which we should not try to use.

Inside my visual.ts I have the normal sections :

  • import declarations
  • export class Visual implements IVisual
  • constructor(options: VisualConstructorOptions)
  • public update(options: VisualUpdateOptions)
  • parseSettings
  • enumerateObjectInstances


I need some help (or point me in the right direction) to take that user selected 'date'

and make power bi report filter all other visuals, like a normal slicer.

What do you suggest ?

 

Note : I already have the "supportsSynchronizingFilterState": true  option inside capabilities.json to enable calendar sync, that part is working, since I have a single element I'm filtering from.

 

Attached a picture of the control I'm using ... (displayed from inside a Report on Power BI service)

datepicker control for PBI custom visual

datepicker_screen.png

My users want it to default to yesterday when they open the report... ( I created a ts formula for that)

the Today button is not enabled (as requested by them)


Thanks for all,

Andres

1 REPLY 1
andres777
Advocate III
Advocate III

The help found so far is this recent document...

 

https://docs.microsoft.com/en-us/power-bi/developer/visuals/filter-api

 

and

Sample:

https://github.com/microsoft/powerbi-visuals-streamgraph/blob/master/src/visual.ts#L552-L556

 

I was trying to use the BasicFilter, with applyJasonFilter

but ended up using Advanced Filter passing both start and end dates to be the same.

converted dates with ....   value: start.toISOString().

 

            let advancedFilter = new AdvancedFilter(this.filterTarget, "And", [{
                operator: "GreaterThanOrEqual",
                value: start.toISOString()
            }, {
                operator: "LessThan",
                value: end.toISOString()
            }])
//applyJsonFilter(filter: powerbi.IFilter | powerbi.IFilter[], objectName: string, propertyName: string, action: powerbi.FilterAction): void this.host.applyJsonFilter(advancedFilter, "general", "filter", powerbi.FilterAction.merge);
 

Thanks Ilfat Galief from Microsoft for your help.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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