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.
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 :
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
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
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
17 | |
2 | |
2 | |
1 | |
1 |
User | Count |
---|---|
21 | |
2 | |
2 | |
2 | |
2 |