<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Issue with filtering not working after pbiviz package in Power BI Custom Visual in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Issue-with-filtering-not-working-after-pbiviz-package-in-Power/m-p/3967124#M53009</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/752639"&gt;@TheMoM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;What type of filter effects not works? The default visual filter or the custom filter effects? Can you please share some more detail about these?&lt;/P&gt;
&lt;P&gt;&lt;A href="http://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to Get Your Question Answered Quickly&amp;nbsp;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Xiaoxin Sheng&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jun 2024 01:15:27 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-06-03T01:15:27Z</dc:date>
    <item>
      <title>Issue with filtering not working after pbiviz package in Power BI Custom Visual</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Issue-with-filtering-not-working-after-pbiviz-package-in-Power/m-p/3963687#M52986</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello Power BI Community&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;I am experiencing an issue with a custom Power BI visual that I am developing&lt;/SPAN&gt;&lt;SPAN&gt;. The visual works perfectly during development when using pbiviz start&lt;/SPAN&gt;&lt;SPAN&gt;, but after packaging it using pbiviz package&lt;/SPAN&gt;&lt;SPAN&gt;, the filtering functionality does not work at all&lt;/SPAN&gt;&lt;SPAN&gt;, no values are modified in the report where I m using it because of the filtering&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;There are no errors or missing steps shown in the console related to the filtering&lt;/SPAN&gt;&lt;SPAN&gt;. In picture you have my applydatefilter function that I use for the filtering in my custom visual if you want to check&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1109021iA0FFFE36AB599E61/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Has anyone encountered a similar issue with Power BI custom visuals&lt;/SPAN&gt;&lt;SPAN&gt;? What could be the possible reasons for this discrepancy between development and packaged visual behavior&lt;/SPAN&gt;&lt;SPAN&gt;?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you in advance for your assistance&lt;/SPAN&gt;&lt;SPAN&gt;!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 08:40:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Issue-with-filtering-not-working-after-pbiviz-package-in-Power/m-p/3963687#M52986</guid>
      <dc:creator>TheMoM</dc:creator>
      <dc:date>2024-05-31T08:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with filtering not working after pbiviz package in Power BI Custom Visual</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Issue-with-filtering-not-working-after-pbiviz-package-in-Power/m-p/3967124#M53009</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/752639"&gt;@TheMoM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;What type of filter effects not works? The default visual filter or the custom filter effects? Can you please share some more detail about these?&lt;/P&gt;
&lt;P&gt;&lt;A href="http://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to Get Your Question Answered Quickly&amp;nbsp;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Xiaoxin Sheng&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 01:15:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Issue-with-filtering-not-working-after-pbiviz-package-in-Power/m-p/3967124#M53009</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-03T01:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with filtering not working after pbiviz package in Power BI Custom Visual</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Issue-with-filtering-not-working-after-pbiviz-package-in-Power/m-p/3971633#M53082</link>
      <description>&lt;P&gt;The visual of the filter work well, what&amp;nbsp; does not work is the filter when I m using pbiviz package which means when modifying the dates, the other data in the report does not change, but somehow this problem is not present when using pbiviz start to show the visual. &amp;nbsp;I m also thinking right now that the problem is not in the filter function, so I will give you my entire visual.ts code if you want to check. Also, the console.log will not help me to find the error because when using it every function seem to work fine.&lt;BR /&gt;&lt;BR /&gt;Here’s my visual.ts code&amp;nbsp;:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;"use strict";&lt;/P&gt;&lt;P&gt;// Import necessary libraries and styles&lt;BR /&gt;import "core-js/stable";&lt;BR /&gt;import "regenerator-runtime/runtime";&lt;BR /&gt;import './../style/visual.less';&lt;BR /&gt;import 'bootstrap-slider/dist/css/bootstrap-slider.min.css';&lt;BR /&gt;import Slider from 'bootstrap-slider';&lt;BR /&gt;import * as $ from 'jquery';&lt;BR /&gt;import powerbi from "powerbi-visuals-api";&lt;/P&gt;&lt;P&gt;// Import Power BI types&lt;BR /&gt;import DataView = powerbi.DataView;&lt;BR /&gt;import IVisualHost = powerbi.extensibility.IVisualHost;&lt;BR /&gt;import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions;&lt;BR /&gt;import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions;&lt;BR /&gt;import { AdvancedFilter, IFilterColumnTarget } from "powerbi-models";&lt;/P&gt;&lt;P&gt;// Import settings model&lt;BR /&gt;import { VisualFormattingSettingsModel } from "./settings";&lt;/P&gt;&lt;P&gt;// Interface for date range data points&lt;BR /&gt;interface DateRangeDataPoint {&lt;BR /&gt;category: string;&lt;BR /&gt;minDate: string;&lt;BR /&gt;maxDate: string;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Main Visual class&lt;BR /&gt;export class Visual implements powerbi.extensibility.visual.IVisual {&lt;BR /&gt;private target: HTMLElement;&lt;BR /&gt;private host: IVisualHost;&lt;/P&gt;&lt;P&gt;private dateRangeContainer: HTMLDivElement;&lt;BR /&gt;private dateInputStart: HTMLInputElement;&lt;BR /&gt;private dateInputEnd: HTMLInputElement;&lt;BR /&gt;private sliderElement: HTMLInputElement;&lt;BR /&gt;private sliderInstance: Slider;&lt;/P&gt;&lt;P&gt;private settings: VisualFormattingSettingsModel;&lt;BR /&gt;private minDateValue: number;&lt;BR /&gt;private maxDateValue: number;&lt;BR /&gt;private isApplyingFilter: boolean = false;&lt;BR /&gt;private lastAppliedStartDate: string;&lt;BR /&gt;private lastAppliedEndDate: string;&lt;/P&gt;&lt;P&gt;// Constructor&lt;BR /&gt;constructor(options: VisualConstructorOptions) {&lt;BR /&gt;this.target = options.element;&lt;BR /&gt;this.host = options.host;&lt;/P&gt;&lt;P&gt;// Create date range container and inputs&lt;BR /&gt;this.dateRangeContainer = document.createElement('div');&lt;BR /&gt;this.dateRangeContainer.className = 'date-range-container';&lt;/P&gt;&lt;P&gt;this.dateInputStart = document.createElement('input');&lt;BR /&gt;this.dateInputStart.type = 'date';&lt;BR /&gt;this.dateInputStart.className = 'date-input';&lt;/P&gt;&lt;P&gt;this.dateInputEnd = document.createElement('input');&lt;BR /&gt;this.dateInputEnd.type = 'date';&lt;BR /&gt;this.dateInputEnd.className = 'date-input';&lt;/P&gt;&lt;P&gt;this.sliderElement = document.createElement('input');&lt;BR /&gt;this.sliderElement.type = 'text';&lt;BR /&gt;this.sliderElement.className = 'slider';&lt;/P&gt;&lt;P&gt;this.dateRangeContainer.appendChild(this.dateInputStart);&lt;BR /&gt;this.dateRangeContainer.appendChild(this.dateInputEnd);&lt;/P&gt;&lt;P&gt;this.target.appendChild(this.dateRangeContainer);&lt;BR /&gt;this.target.appendChild(this.sliderElement);&lt;/P&gt;&lt;P&gt;this.initializeSlider();&lt;/P&gt;&lt;P&gt;// Add event listeners to date inputs&lt;BR /&gt;this.dateInputStart.addEventListener('change', () =&amp;gt; this.onDateInputChange());&lt;BR /&gt;this.dateInputEnd.addEventListener('change', () =&amp;gt; this.onDateInputChange());&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Initialize the slider&lt;BR /&gt;private initializeSlider() {&lt;BR /&gt;this.sliderInstance = new Slider(this.sliderElement, {&lt;BR /&gt;min: 0,&lt;BR /&gt;max: 100,&lt;BR /&gt;value: [0, 100],&lt;BR /&gt;tooltip: 'hide',&lt;BR /&gt;tooltip_split: false&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Add event listener for slider stop event&lt;BR /&gt;this.sliderInstance.on('slideStop', (event) =&amp;gt; {&lt;BR /&gt;const values = this.sliderInstance.getValue();&lt;BR /&gt;const minDate = values[0];&lt;BR /&gt;const maxDate = values[1];&lt;BR /&gt;this.dateInputStart.value = new Date(minDate).toISOString().split('T')[0];&lt;BR /&gt;this.dateInputEnd.value = new Date(maxDate).toISOString().split('T')[0];&lt;BR /&gt;this.applyDateFilter(this.dateInputStart.value, this.dateInputEnd.value);&lt;BR /&gt;});&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Update slider range&lt;BR /&gt;private updateSliderRange(minDateValue: number, maxDateValue: number) {&lt;BR /&gt;if (this.minDateValue !== minDateValue || this.maxDateValue !== maxDateValue) {&lt;BR /&gt;this.sliderInstance.setAttribute('min', minDateValue);&lt;BR /&gt;this.sliderInstance.setAttribute('max', maxDateValue);&lt;BR /&gt;this.sliderInstance.setValue([minDateValue, maxDateValue]);&lt;/P&gt;&lt;P&gt;this.dateInputStart.value = new Date(minDateValue).toISOString().split('T')[0];&lt;BR /&gt;this.dateInputEnd.value = new Date(maxDateValue).toISOString().split('T')[0];&lt;/P&gt;&lt;P&gt;// Save the new values to prevent unnecessary updates&lt;BR /&gt;this.minDateValue = minDateValue;&lt;BR /&gt;this.maxDateValue = maxDateValue;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Update function called by Power BI&lt;BR /&gt;public async update(options: VisualUpdateOptions) {&lt;BR /&gt;if (this.isApplyingFilter) {&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (options.dataViews &amp;amp;&amp;amp; options.dataViews[0]) {&lt;BR /&gt;const dataView: DataView = options.dataViews[0];&lt;BR /&gt;const dateRangeDataPoints = this.createSelectorDataPoints(options, this.host);&lt;/P&gt;&lt;P&gt;if (dateRangeDataPoints.length &amp;gt; 0) {&lt;BR /&gt;const newMinDateValue = new Date(dateRangeDataPoints[0].minDate).getTime();&lt;BR /&gt;const newMaxDateValue = new Date(dateRangeDataPoints[0].maxDate).getTime();&lt;/P&gt;&lt;P&gt;if (newMinDateValue !== this.minDateValue || newMaxDateValue !== this.maxDateValue) {&lt;BR /&gt;this.updateSliderRange(newMinDateValue, newMaxDateValue);&lt;BR /&gt;this.applyDateFilter(this.dateInputStart.value, this.dateInputEnd.value);&lt;/P&gt;&lt;P&gt;// Sleep for 10 seconds to prevent re-entrant calls&lt;BR /&gt;await new Promise((resolve) =&amp;gt; setTimeout(resolve, 10000));&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;this.clear();&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;this.clear();&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Create selector data points from data view&lt;BR /&gt;private createSelectorDataPoints(options: VisualUpdateOptions, host: IVisualHost): DateRangeDataPoint[] {&lt;BR /&gt;const dateRangeDataPoints: DateRangeDataPoint[] = [];&lt;BR /&gt;const dataViews = options.dataViews;&lt;/P&gt;&lt;P&gt;if (!dataViews || !dataViews[0]) {&lt;BR /&gt;return dateRangeDataPoints;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const dataView = dataViews[0];&lt;BR /&gt;if (!dataView.categorical) {&lt;BR /&gt;return dateRangeDataPoints;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const categorical = dataView.categorical;&lt;BR /&gt;if (!categorical.categories || !categorical.values) {&lt;BR /&gt;return dateRangeDataPoints;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const category = categorical.categories[0];&lt;BR /&gt;const minDateValue = categorical.values[0];&lt;BR /&gt;const maxDateValue = categorical.values[1];&lt;/P&gt;&lt;P&gt;if (!category || !minDateValue || !maxDateValue) {&lt;BR /&gt;return dateRangeDataPoints;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Assuming you only need the first value&lt;BR /&gt;dateRangeDataPoints.push({&lt;BR /&gt;category: `${category.values[0]}`,&lt;BR /&gt;minDate: this.ensureDateFormat(`${minDateValue.values[0]}`),&lt;BR /&gt;maxDate: this.ensureDateFormat(`${maxDateValue.values[0]}`)&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;return dateRangeDataPoints;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Ensure date format is correct&lt;BR /&gt;private ensureDateFormat(dateString: string): string {&lt;BR /&gt;const date = new Date(dateString);&lt;BR /&gt;return date.toISOString().split('.')[0] + "Z";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Clear the visual&lt;BR /&gt;private clear() {&lt;BR /&gt;this.sliderInstance.setValue([0, 100]);&lt;BR /&gt;this.dateInputStart.value = "";&lt;BR /&gt;this.dateInputEnd.value = "";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Event handler for date input change&lt;BR /&gt;private onDateInputChange() {&lt;BR /&gt;const startDate = new Date(this.dateInputStart.value).getTime();&lt;BR /&gt;const endDate = new Date(this.dateInputEnd.value).getTime();&lt;BR /&gt;this.sliderInstance.setValue([startDate, endDate]);&lt;BR /&gt;this.applyDateFilter(this.dateInputStart.value, this.dateInputEnd.value);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Apply date filter&lt;BR /&gt;private async applyDateFilter(startDate: string, endDate: string): Promise&amp;lt;void&amp;gt; {&lt;BR /&gt;if (this.lastAppliedStartDate === startDate &amp;amp;&amp;amp; this.lastAppliedEndDate === endDate) {&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;this.lastAppliedStartDate = startDate;&lt;BR /&gt;this.lastAppliedEndDate = endDate;&lt;/P&gt;&lt;P&gt;const target: IFilterColumnTarget = {&lt;BR /&gt;table: "document",&lt;BR /&gt;column: "document_creation_date"&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;const filter = new AdvancedFilter(target, "And", [&lt;BR /&gt;{&lt;BR /&gt;operator: "GreaterThanOrEqual",&lt;BR /&gt;value: this.ensureDateFormat(startDate)&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;operator: "LessThanOrEqual",&lt;BR /&gt;value: this.ensureDateFormat(endDate)&lt;BR /&gt;}&lt;BR /&gt;]);&lt;/P&gt;&lt;P&gt;this.isApplyingFilter = true;&lt;BR /&gt;(this.host as any).applyJsonFilter(&lt;BR /&gt;filter,&lt;BR /&gt;"dataPoint",&lt;BR /&gt;"filter",&lt;BR /&gt;powerbi.FilterAction.merge&lt;BR /&gt;);&lt;BR /&gt;this.isApplyingFilter = false;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 13:45:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Issue-with-filtering-not-working-after-pbiviz-package-in-Power/m-p/3971633#M53082</guid>
      <dc:creator>TheMoM</dc:creator>
      <dc:date>2024-06-04T13:45:27Z</dc:date>
    </item>
  </channel>
</rss>

