<?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 Custom Date Range Selector - Basic filters for dates in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Date-Range-Selector-Basic-filters-for-dates/m-p/3481999#M8113</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a custom date range selector using a React component. I have confirmed that my component correctly passes a start and end date, which I then use to create an array of dates that I want to filter my data with in Power BI.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run my visual in PBI Service and select my data range I see no change the data I am trying to filter. It leads me to believe I am apply the fillter incorrectly. I searched and tried a lot of different approaches but still haven't gotten it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does any one know what I am doing wrong? Any suggestions are greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;private handleSliderChange = (range: [number, number]) =&amp;gt; {

//Error handling
        if (!range || range.length !== 2 || typeof range[0] === 'undefined' || typeof range[1] === 'undefined') {
            return;
        }
//Gets start and end date from React component and creates and contiguous array of dates from start to end date    
        const startDate = new Date(range[0]);
        const endDate = new Date(range[1]);
        
        const contiguousDates: Date[] = [];
        for (let d = new Date(startDate); d &amp;lt;= endDate; d.setDate(d.getDate() + 1)) {
            contiguousDates.push(new Date(d));
        }
 //Gets Power BI table and column names for filter       
        const table = categories.source.queryName.substring(0, categories.source.queryName.indexOf('.'))
        const colum = categories.source.displayName

//formats array of dates
        const values = contiguousDates.map(date =&amp;gt; date.toISOString());

//Defines basic filter       
        const basicFilter: models.IBasicFilter = {
            $schema: "https://powerbi.com/product/schema#basic",
            filterType: models.FilterType.Basic,
            target: {
                table: table,
                column: colum
            },
            operator: "In",
            values: values
        };

//applies filter        
        this.visualHost.applyJsonFilter(basicFilter, "general", "Filter", powerbi.FilterAction.merge);
    };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Oct 2023 21:58:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-10-17T21:58:38Z</dc:date>
    <item>
      <title>Custom Date Range Selector - Basic filters for dates</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Date-Range-Selector-Basic-filters-for-dates/m-p/3481999#M8113</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a custom date range selector using a React component. I have confirmed that my component correctly passes a start and end date, which I then use to create an array of dates that I want to filter my data with in Power BI.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run my visual in PBI Service and select my data range I see no change the data I am trying to filter. It leads me to believe I am apply the fillter incorrectly. I searched and tried a lot of different approaches but still haven't gotten it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does any one know what I am doing wrong? Any suggestions are greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;private handleSliderChange = (range: [number, number]) =&amp;gt; {

//Error handling
        if (!range || range.length !== 2 || typeof range[0] === 'undefined' || typeof range[1] === 'undefined') {
            return;
        }
//Gets start and end date from React component and creates and contiguous array of dates from start to end date    
        const startDate = new Date(range[0]);
        const endDate = new Date(range[1]);
        
        const contiguousDates: Date[] = [];
        for (let d = new Date(startDate); d &amp;lt;= endDate; d.setDate(d.getDate() + 1)) {
            contiguousDates.push(new Date(d));
        }
 //Gets Power BI table and column names for filter       
        const table = categories.source.queryName.substring(0, categories.source.queryName.indexOf('.'))
        const colum = categories.source.displayName

//formats array of dates
        const values = contiguousDates.map(date =&amp;gt; date.toISOString());

//Defines basic filter       
        const basicFilter: models.IBasicFilter = {
            $schema: "https://powerbi.com/product/schema#basic",
            filterType: models.FilterType.Basic,
            target: {
                table: table,
                column: colum
            },
            operator: "In",
            values: values
        };

//applies filter        
        this.visualHost.applyJsonFilter(basicFilter, "general", "Filter", powerbi.FilterAction.merge);
    };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 21:58:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Date-Range-Selector-Basic-filters-for-dates/m-p/3481999#M8113</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-17T21:58:38Z</dc:date>
    </item>
  </channel>
</rss>

