<?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: Custom Power BI visual (date picker slicer)  not work with SELECTEDVALUE() in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4812351#M12778</link>
    <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/585150"&gt;@johnbasha33&lt;/a&gt;&amp;nbsp;My issue still exists? how to make the customer visual to work with SELECTEDVALUE(). Do you have any idea ? thank you again.&lt;/P&gt;</description>
    <pubDate>Sun, 31 Aug 2025 01:57:11 GMT</pubDate>
    <dc:creator>lulalagulu</dc:creator>
    <dc:date>2025-08-31T01:57:11Z</dc:date>
    <item>
      <title>Custom Power BI visual (date picker slicer)  not work with SELECTEDVALUE()</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4799696#M12747</link>
      <description>&lt;H2&gt;Problem Description&lt;/H2&gt;&lt;P&gt;&lt;STRONG&gt;Issue&lt;/STRONG&gt;: Custom Power BI visual (date picker slicer) cannot properly integrate with Power Query parameters and DAX functions like&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;SELECTEDVALUE()&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;VALUES()&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Context&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Created a custom Power BI visual that functions as a date picker slicer&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The visual is intended to work with Power Query parameters to filter data&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;When users select a date in the custom visual, it should update the parameter value&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;However,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;SELECTEDVALUE(column)&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;PRE&gt;VALUES(column)&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;return&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;PRE&gt;BLANK()&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;instead of the selected date value&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Interestingly,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;ISFILTERED(column)&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;returns&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;PRE&gt;TRUE&lt;/PRE&gt;&lt;/DIV&gt;, indicating that filtering is working but selection context is not&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Expected Behavior&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Built-in Power BI slicers work perfectly with parameters - when a user selects a value,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;SELECTEDVALUE()&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;returns that value&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Custom visual should behave similarly to built-in slicers&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H2&gt;Attempted Solutions&lt;/H2&gt;&lt;H3&gt;1.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;JSON Filter Approach&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Used&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;host.applyJsonFilter()&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with both Basic and Advanced filter types&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Tried different filter operators (&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;In&lt;/PRE&gt;&lt;/DIV&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;PRE&gt;Is&lt;/PRE&gt;&lt;/DIV&gt;)&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Experimented with various date formats (ISO strings, original date strings)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Used both&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;FilterAction.merge&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;PRE&gt;FilterAction.replace&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Added&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;requireSingleSelection: true&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for Basic filters&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;2.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Selection Manager Approach&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Implemented&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;ISelectionManager.select()&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;alongside JSON filters&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Created proper&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;ISelectionId&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;objects using&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;PRE&gt;createSelectionIdBuilder().withCategory()&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Ensured single selection by calling&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;clear()&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;before&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;PRE&gt;select()&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Mapped date values to selection IDs using consistent date formatting&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;3.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Hybrid Approach&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Combined both JSON Filter and Selection Manager methods&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Applied JSON filters for Power Query parameter integration&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Used Selection Manager for DAX function compatibility&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Synchronized date formats between both approaches&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;4.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Date Format Consistency&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Ensured consistent date formatting across all methods&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Used both ISO format (&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;YYYY-MM-DD&lt;/PRE&gt;&lt;/DIV&gt;) and custom format keys&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Handled different input date types (string, number, Date objects)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;5.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Filter Configuration Variations&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Tested different filter schemas and configurations&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Experimented with logical operators and condition structures&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Tried multiple filter targets and naming conventions&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H2&gt;Current Status&lt;/H2&gt;&lt;P&gt;&lt;STRONG&gt;What Works&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Power Query parameters receive filter values correctly&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;ISFILTERED()&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;returns&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;PRE&gt;TRUE&lt;/PRE&gt;&lt;/DIV&gt;, confirming filter context exists&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Visual filtering functionality works as expected&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Date selection and UI interaction work properly&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;What Doesn't Work&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;SELECTEDVALUE()&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;consistently returns&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;PRE&gt;BLANK()&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;VALUES()&lt;/PRE&gt;&lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;doesn't return the selected date value&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;DAX functions cannot access the selection context created by the custom visual&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H2&gt;Root Cause Hypothesis&lt;/H2&gt;&lt;P&gt;The issue appears to be a fundamental limitation of Power BI's custom visual architecture. Built-in slicers have special privileges and mechanisms to create proper DAX selection context, while custom visuals may be restricted in their ability to fully replicate this behavior. The custom visual can create filter context (hence&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;ISFILTERED()&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;works) but cannot establish the single-value selection context required by&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;SELECTEDVALUE()&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This suggests that custom visuals and built-in slicers operate through different mechanisms in Power BI's filtering and selection system, with built-in components having deeper integration with the DAX evaluation engine.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 10:34:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4799696#M12747</guid>
      <dc:creator>lulalagulu</dc:creator>
      <dc:date>2025-08-18T10:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Power BI visual (date picker slicer)  not work with SELECTEDVALUE()</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4805533#M12759</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Short version: custom visuals can push &lt;STRONG data-start="39" data-end="57"&gt;filter context (so &lt;CODE data-start="62" data-end="76"&gt;ISFILTERED() goes TRUE), but they don’t get the same “slicer-privileged” path that guarantees a &lt;STRONG data-start="160" data-end="176"&gt;single-value selection context for DAX. &lt;CODE data-start="204" data-end="221"&gt;SELECTEDVALUE() only returns a value when the engine truly sees exactly one value in context; otherwise it returns BLANK—even if your visual UI shows one date.&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-start="367" data-end="385"&gt;What to check/fix:&lt;/P&gt;
&lt;OL data-start="387" data-end="837"&gt;
&lt;LI data-start="387" data-end="666"&gt;
&lt;P data-start="390" data-end="666"&gt;Target the exact model column&lt;BR data-start="419" data-end="422" /&gt;Make sure your &lt;CODE data-start="437" data-end="454"&gt;applyJsonFilter targets the &lt;STRONG data-start="467" data-end="482"&gt;same column you use in DAX, not a display/derived field. Use a Basic (or Advanced) filter with a single value and &lt;CODE data-start="585" data-end="603"&gt;isInverted:false. Doc: Visual Filter API. &lt;SPAN class="" data-state="closed"&gt;&lt;SPAN class="" data-testid="webpage-citation-pill"&gt;&lt;A class="" href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/filter-api?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Microsoft Learn&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="668" data-end="837"&gt;
&lt;P data-start="671" data-end="837"&gt;Bind it via capabilities (not just ad-hoc)&lt;BR data-start="713" data-end="716" /&gt;In &lt;CODE data-start="719" data-end="738"&gt;capabilities.json, include a &lt;CODE data-start="750" data-end="766"&gt;general.filter property so the filter is persisted and recognized as a visual filter:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"objects": { "general": { "properties": { "filter": { "type": { "filter": {} } } } } }&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P data-start="937" data-end="1114"&gt;(And then call &lt;CODE data-start="952" data-end="1031"&gt;host.applyJsonFilter(filter, "general", "filter", powerbi.FilterAction.merge).) Example patterns are in the Sample Slicer. &lt;SPAN class="" data-state="closed"&gt;&lt;SPAN class="" data-testid="webpage-citation-pill"&gt;&lt;A class="" href="https://github.com/microsoft/powerbi-visuals-sampleslicer/blob/master/doc/UsingAdvancedFilterAPI.md?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;GitHub&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;A class="" href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/filter-api?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Microsoft Learn&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P data-start="1119" data-end="1186"&gt;Prove whether it’s single-select from DAX’s point of view&lt;BR data-start="1176" data-end="1179" /&gt;Create:&lt;BR /&gt;&lt;BR /&gt;HowMany = COUNTROWS(VALUES('DimDate'[Date]))&lt;BR /&gt;Picked = SELECTEDVALUE('DimDate'[Date])&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P data-start="1285" data-end="1495"&gt;If &lt;CODE data-start="1288" data-end="1297"&gt;HowMany ≠ 1, &lt;CODE data-start="1303" data-end="1311"&gt;Picked will be BLANK. That means your filter didn’t collapse to one value in the model (commonly because of hidden hierarchies, formatting mismatches, wrong target column, or relationships).&lt;/CODE&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;OL start="4" data-start="1497" data-end="3032"&gt;
&lt;LI data-start="1497" data-end="1860"&gt;
&lt;P data-start="1500" data-end="1860"&gt;Avoid date hierarchies / auto date-time&lt;BR data-start="1539" data-end="1542" /&gt;Make sure you’re filtering the &lt;STRONG data-start="1573" data-end="1593"&gt;base date column (type Date) — not the auto date hierarchy or a formatted text field. Hierarchies often lead to multiple values in context. Several threads show &lt;CODE data-start="1738" data-end="1753"&gt;SELECTEDVALUE coming back blank when a hierarchy or mismatched column is involved. &lt;SPAN class="" data-state="closed"&gt;&lt;SPAN class="" data-testid="webpage-citation-pill"&gt;&lt;A class="" href="https://community.fabric.microsoft.com/t5/Desktop/SELECTEDVALUE-on-a-slicer-returning-Blank/td-p/3655545?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Microsoft Fabric Community&lt;SPAN class=""&gt;+2&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Microsoft Fabric Community&lt;SPAN class=""&gt;+2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="1862" data-end="2063"&gt;
&lt;P data-start="1865" data-end="2063"&gt;Relationships must propagate to the measure’s table&lt;BR data-start="1916" data-end="1919" /&gt;If your date column sits in a different table and there’s no (active) relationship, the filter won’t reach the measure. Check the model diagram.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="2065" data-end="2521"&gt;
&lt;P data-start="2068" data-end="2521"&gt;Don’t expect &lt;CODE data-start="2081" data-end="2098"&gt;applyJsonFilter to filter &lt;STRONG data-start="2109" data-end="2121"&gt;your own visual’s dataView&lt;BR data-start="2139" data-end="2142" /&gt;By design, calling &lt;CODE data-start="2161" data-end="2178"&gt;applyJsonFilter updates the report filter state; other visuals will see it, but your visual’s current &lt;CODE data-start="2265" data-end="2275"&gt;dataView won’t retro-filter in memory. Request an update (&lt;CODE data-start="2325" data-end="2341"&gt;host.refresh() or wait for update via &lt;CODE data-start="2365" data-end="2380"&gt;onDataChanged) and base logic on the model column, not your internal array. This behavior is highlighted in dev Q&amp;amp;A. &lt;SPAN class="" data-state="closed"&gt;&lt;SPAN class="" data-testid="webpage-citation-pill"&gt;&lt;A class="" href="https://stackoverflow.com/questions/76279165/power-bi-custom-visual-retrieve-filtered-data-after-using-applyjsonfilter-me?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Stack Overflow&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="2523" data-end="2806"&gt;
&lt;P data-start="2526" data-end="2806"&gt;SelectionManager ≠ filter context&lt;BR data-start="2559" data-end="2562" /&gt;&lt;CODE data-start="2562" data-end="2589"&gt;selectionManager.select() is for cross-highlight and selections, not guaranteed single-value filter context for DAX. Treat SelectionManager as UI affordance; use the Filter API to create the model filter. &lt;SPAN class="" data-state="closed"&gt;&lt;SPAN class="" data-testid="webpage-citation-pill"&gt;&lt;A class="" href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/filter-api?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Microsoft Learn&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="2808" data-end="3032"&gt;
&lt;UL data-start="3108" data-end="3353"&gt;
&lt;LI data-start="3108" data-end="3164"&gt;
&lt;P data-start="3110" data-end="3164"&gt;Declare a categorical data role for the date column.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="3165" data-end="3208"&gt;
&lt;P data-start="3167" data-end="3208"&gt;Persist the filter in &lt;CODE data-start="3189" data-end="3205"&gt;general.filter.&lt;/CODE&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="3209" data-end="3293"&gt;
&lt;P data-start="3211" data-end="3293"&gt;Apply a &lt;STRONG data-start="3219" data-end="3228"&gt;Basic filter with a single ISO date value against &lt;CODE data-start="3273" data-end="3290"&gt;'DimDate'[Date].&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="3294" data-end="3353"&gt;
&lt;P data-start="3296" data-end="3353"&gt;Validate with &lt;CODE data-start="3310" data-end="3350"&gt;COUNTROWS(VALUES('DimDate'[Date])) = 1.&lt;/CODE&gt;&lt;/P&gt;
&lt;P data-start="3355" data-end="3463"&gt;Docs and sample: Filter API and Sample Slicer’s Advanced Filter usage. &lt;SPAN class="" data-state="closed"&gt;&lt;SPAN class="" data-testid="webpage-citation-pill"&gt;&lt;A class="" href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/filter-api?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Microsoft Learn&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;A class="" href="https://github.com/microsoft/powerbi-visuals-sampleslicer/blob/master/doc/UsingAdvancedFilterAPI.md?utm_source=chatgpt.com" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;GitHub&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P data-start="3465" data-end="3742"&gt;Bottom line: there isn’t a secret “RLS-like” privilege you can tap from a custom visual. You &lt;EM data-start="3558" data-end="3563"&gt;can get &lt;CODE data-start="3568" data-end="3585"&gt;SELECTEDVALUE() to behave, but only when the filter you apply collapses the model to exactly one value on the real column, with relationships and hierarchies set correctly.&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT color="#800000"&gt;Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P data-start="1119" data-end="1186"&gt;&lt;SPAN&gt;Power Query parameters won’t feed DAX context&lt;/SPAN&gt;&lt;/P&gt;
&lt;P data-start="2811" data-end="3032"&gt;PQ parameters are evaluated at refresh/mashup time. They don’t create row context for measures. Your “parameter updates” can work, but DAX &lt;CODE data-start="2998" data-end="3015"&gt;SELECTEDVALUE() won’t read them.&lt;/CODE&gt;&lt;/P&gt;
&lt;P data-start="3034" data-end="3106"&gt;If you want a working baseline, replicate the &lt;STRONG data-start="3080" data-end="3097"&gt;Sample Slicer pattern:&lt;BR /&gt;&lt;/STRONG&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1250381"&gt;@lulalagulu&lt;/a&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sat, 23 Aug 2025 07:23:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4805533#M12759</guid>
      <dc:creator>johnbasha33</dc:creator>
      <dc:date>2025-08-23T07:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Power BI visual (date picker slicer)  not work with SELECTEDVALUE()</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4805797#M12768</link>
      <description>&lt;P&gt;Thank you for answering me. I&amp;nbsp;sincerely appreciate it. I developed the visual as a calendar picker to work with power query M parameter. It worked well with M parameter. Here is the code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export class Visual implements IVisual {
    private target: HTMLElement;
    private host: IVisualHost;

    private selectionManager: ISelectionManager;

    private formattingSettingsService: FormattingSettingsService;
    private formattingSettings: VisualFormattingSettingsModel;

    private inputContainer: HTMLDivElement;
    private dateInput: HTMLInputElement;
    private currentDataView: DataView | null; // 用于存储最新的数据视图

    private dataPoint: Map&amp;lt;string, ISelectionId&amp;gt; = new Map();

    constructor(options: VisualConstructorOptions) {
        this.target = options.element;
        this.host = options.host;
        this.formattingSettingsService = new FormattingSettingsService();
        this.selectionManager = this.host.createSelectionManager();

        // Clear existing content
        this.target.innerHTML = '';

        // 创建UI元素 (输入框和图标)
        this.createUIElements();


    }

    private createUIElements(): void {
        const label = document.createElement('div');
        label.className = 'date-label';
        label.textContent = '日期';
        label.style.fontWeight = 'bold';
        label.style.marginBottom = '5px';
        this.target.appendChild(label);

        this.inputContainer = document.createElement('div');
        this.inputContainer.className = 'input-container';
        this.inputContainer.style.display = 'flex';
        this.inputContainer.style.alignItems = 'center';
        this.inputContainer.style.border = '1px solid #ccc';
        this.inputContainer.style.borderRadius = '4px';
        this.inputContainer.style.padding = '4px 8px';
        this.inputContainer.style.backgroundColor = 'white';
        this.target.appendChild(this.inputContainer);

        this.dateInput = document.createElement('input');
        this.dateInput.type = 'text';
        this.dateInput.readOnly = true;
        this.dateInput.placeholder = 'YYYY-MM-DD';
        this.dateInput.style.border = 'none';
        this.dateInput.style.outline = 'none';
        this.dateInput.style.width = '100%';
        this.dateInput.style.fontSize = '14px';
        this.inputContainer.appendChild(this.dateInput);

        const dateIcon = document.createElement('div');
        dateIcon.innerHTML = '📅';
        dateIcon.style.cursor = 'pointer';
        dateIcon.style.marginLeft = '4px';
        dateIcon.addEventListener('click', (event) =&amp;gt; {
            event.stopPropagation();
            this.openCalendarDialog(); // 调用打开对话框的方法
        });
        this.inputContainer.appendChild(dateIcon);
    }

    private applyDateFilter(date: string): void {
        if (!this.host || !this.host.applyJsonFilter) return;
    
        // 获取或确定要筛选的表和列
        let tableName: string | undefined;
        let columnName: string | undefined;
        
        if (this.currentDataView?.metadata?.columns) {
            const dateColumn = this.currentDataView.metadata.columns.find(col =&amp;gt; col.roles &amp;amp;&amp;amp; col.roles['Date']);
            if (dateColumn?.queryName) {
                [tableName, columnName] = dateColumn.queryName.split('.');
            }
        }
    
        if (!tableName || !columnName) return;
        
        const filter = {
            $schema: "https://powerbi.com/product/schema#basic",
            target: {
                table: tableName,
                column: columnName
            },
            filterType: models.FilterType.Basic,
           operator: "In",
            values: [ new Date(date).toISOString()],
            requireSingleSelection : true
        };
        
       
        this.host.applyJsonFilter(filter, "general", "filter", powerbi.FilterAction.merge);
    }


    private getDateColumnRange(): { minDate: Date, maxDate: Date } {
        const defaultRange = {
            minDate: new Date(1990, 1, 1),
            maxDate: new Date()
        };

        if (!this.currentDataView || !this.currentDataView.categorical) {
            return defaultRange;
        }

        const dates = this.currentDataView.categorical.categories![0].values
            .map(row =&amp;gt; {
                const value = row;
                // 处理不同类型的日期值
                if (typeof value === 'string') {
                    return new Date(value);
                } else if (typeof value === 'number') {
                    return new Date(value);
                } else if (value instanceof Date) {
                    return value;
                }
                return null;
            })
            .filter((date): date is Date =&amp;gt; date !== null &amp;amp;&amp;amp; !isNaN(date.getTime()));

        if (dates.length === 0) {
            return defaultRange;
        }

        dates.sort((a, b) =&amp;gt; a.getTime() - b.getTime());
        return {
            minDate: dates[0],
            maxDate: dates[dates.length - 1]
        };
    }

    private handleDialogResult(result: ModalDialogResult, targetElement: HTMLElement, sManager: ISelectionManager, dataPoint: Map&amp;lt;string, ISelectionId&amp;gt;) {
        if (result.actionId === DialogAction.OK) {
            const resultState = &amp;lt;DatePickerDialogResult&amp;gt;result.resultState;
            const selectedDate = new Date(resultState.date);
    
            let formatted_date = formatDate(selectedDate);
            if (targetElement instanceof HTMLInputElement) {
                targetElement.value = formatted_date;
            } else {
                targetElement.textContent = formatted_date;
            }
            
        
            this.applyDateFilter(formatted_date);
            
       
            // let selectedId = dataPoint.get(formatted_date);
            // if (selectedId) {
            //     sManager.select(selectedId);
            // }
        }
    
    }

    private openCalendarDialog(): void {
        const dateRange = this.getDateColumnRange();

        let startDate = new Date();
        if (startDate &amp;lt; dateRange.minDate) {
            startDate = dateRange.minDate;
        } else if (startDate &amp;gt; dateRange.maxDate) {
            startDate = dateRange.maxDate
        }

        const initialDialogState = {
            startDate: startDate,
            minDate: dateRange.minDate,
            maxDate: dateRange.maxDate
        };
        const position = {
            type: VisualDialogPositionType.RelativeToVisual,
            left: 0,
            top: 60
        };

        const size = { width: 360, height: 300 };
        const dialogOptions = {
            actionButtons: dialogActionsButtons,
            size: size,
            position: position,
            title: ""
        };


        // const initialState: { selectedDate?: string } = {};
        if (this.dateInput.value) {
            // 如果输入框有日期，作为初始值传给对话框
            initialDialogState.startDate = new Date(this.dateInput.value); // this.formatDate(selectedDate) -&amp;gt; YYYY/MM/DD
        }

        this.host.openModalDialog(
            DatePickerDialog.id,
            dialogOptions,
            initialDialogState // 传递初始日期给对话框
        ).then(result =&amp;gt; {
            console.log("Dialog closed with result:", result);
            this.handleDialogResult(result, this.dateInput, this.selectionManager, this.dataPoint);
        }).catch(error =&amp;gt; {
            console.error("Error opening date picker dialog:", error);
        });
    }



    public destroy(): void {

    }

    public update(options: VisualUpdateOptions) {
        console.log("filter: " + JSON.stringify(options.jsonFilters, null, 4));
        this.handleDataView(options.dataViews);
    }

    private handleDataView(dataViews: DataView[]) {
        if (!dataViews || dataViews.length == 0) {
            this.currentDataView = null;
            return;
        }

      
        //update the current date view
        this.currentDataView = dataViews[0];

        if (this.currentDataView.categorical &amp;amp;&amp;amp; this.currentDataView.categorical.categories &amp;amp;&amp;amp; this.currentDataView.categorical.categories.length &amp;gt; 0) {
            this.updateSelection(this.currentDataView.categorical);
        } else {
            this.dataPoint.clear();
            this.dateInput.value = '';
        }


        //sync the formattingSettings
        this.formattingSettings = this.formattingSettingsService.populateFormattingSettingsModel(
            VisualFormattingSettingsModel,
            this.currentDataView
        );

        this.updateFormatting();



    }

    private updateSelection(currentCategorical: powerbi.DataViewCategorical) {

        const categories = currentCategorical.categories;
        // get count of category elements
        const categoriesCount = categories![0].values.length;

        // iterate all categories to generate selection and create button elements to use selections
        for (let categoryIndex = 0; categoryIndex &amp;lt; categoriesCount; categoryIndex++) {
            const categoryValue: powerbi.PrimitiveValue = categories![0].values[categoryIndex];

            const categorySelectionId = this.host.createSelectionIdBuilder()
                .withCategory(categories![0], categoryIndex) // we have only one category (only one `Manufacturer` column)
                .createSelectionId();

       
            //console.log(categorySelectionId);

            let pearl: Date | null = null;

           
            if (typeof categoryValue === 'string') {
                pearl = new Date(categoryValue);
            } else if (typeof categoryValue === 'number') {
                pearl = new Date(categoryValue);
            } else if (categoryValue instanceof Date) {
                pearl = categoryValue;
            }

            let key: string = 'null';
            if (pearl !== null &amp;amp;&amp;amp; !isNaN(pearl.getTime())) {
                key = formatDate(pearl);
            }

            this.dataPoint.set(key, categorySelectionId);

        }



    }


    private updateFormatting(): void {
        const labelSettings = this.formattingSettings.labelCard;
        const inputSettings = this.formattingSettings.inputCard;

        // 更新标签样式
        const label = this.target.querySelector('.date-label') as HTMLElement;
        if (label) {
            if (labelSettings.show.value) {
                label.style.display = "block";
                label.textContent = labelSettings.text.value;
                label.style.fontFamily = labelSettings.fontFamily.value;
                label.style.fontSize = `${labelSettings.fontSize.value}px`;
                label.style.color = labelSettings.fontColor.value.value;
            } else {
                label.style.display = "none";
            }
        }

       
        if (this.dateInput) {
            this.dateInput.style.fontFamily = inputSettings.fontFamily.value;
            this.dateInput.style.fontSize = `${inputSettings.fontSize.value}px`;
            this.dateInput.style.color = inputSettings.fontColor.value.value;
        }
    }

    public getFormattingModel(): powerbi.visuals.FormattingModel {
        return this.formattingSettingsService.buildFormattingModel(this.formattingSettings);
    }
}&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;{
  "dataRoles": [
    {
      "name": "Date",
      "displayName": "field",
      "kind": "Grouping"
    }
  ],
  "dataViewMappings": [
    {
      "conditions": [
        {
          "Date": {
            "max": 1
          }
        }
      ],
      "categorical": {
        "categories": {
          "for": {
            "in": "Date"
          }
        }
      }
    }
  ],
  "objects": {
    "general": {
      "displayName": "General",
      "displayNameKey": "formattingGeneral",
      "properties": {
        "filter": {
          "type": {
            "filter": true
          }
        }
      }
    },
    "labelFormatting": {
      "displayName": "Slicer header",
      "properties": {
        "show": {
          "type": {
            "bool": true
          }
        },
        "text": {
          "displayName": "Text",
          "type": {
            "text": true
          }
        },
        "fontFamily": {
          "displayName": "Font",
          "type": {
            "formatting": {
              "fontFamily": true
            }
          }
        },
        "fontSize": {
          "displayName": "Font size",
          "type": {
            "numeric": true
          }
        },
        "fontColor": {
          "displayName": "Font color",
          "type": {
            "fill": {
              "solid": {
                "color": true
              }
            }
          }
        }
      }
    },
    "inputFormatting": {
      "displayName": "Values",
      "properties": {
        "fontFamily": {
          "displayName": "Font",
          "type": {
            "formatting": {
              "fontFamily": true
            }
          }
        },
        "fontSize": {
          "displayName": "Font size",
          "type": {
            "numeric": true
          }
        },
        "fontColor": {
          "displayName": "Font color",
          "type": {
            "fill": {
              "solid": {
                "color": true
              }
            }
          }
        }
      }
    }
  },
  "sorting": {
    "default": {}
  },
  "privileges": [],
  "supportsEmptyDataView": true
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both dim start_date and dim end_date are individual tables without relationship to any table.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-08-24 at 12.59.10.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1293282i543751D64DC0EE39/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-08-24 at 12.59.10.png" alt="Screenshot 2025-08-24 at 12.59.10.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Aug 2025 05:10:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4805797#M12768</guid>
      <dc:creator>lulalagulu</dc:creator>
      <dc:date>2025-08-24T05:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Power BI visual (date picker slicer)  not work with SELECTEDVALUE()</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4812351#M12778</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/585150"&gt;@johnbasha33&lt;/a&gt;&amp;nbsp;My issue still exists? how to make the customer visual to work with SELECTEDVALUE(). Do you have any idea ? thank you again.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Aug 2025 01:57:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4812351#M12778</guid>
      <dc:creator>lulalagulu</dc:creator>
      <dc:date>2025-08-31T01:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Power BI visual (date picker slicer)  not work with SELECTEDVALUE()</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4889180#M12960</link>
      <description>&lt;P&gt;I get back here to announce that it still does not work with&amp;nbsp;&lt;SPAN class=""&gt;SELECTEDVALUE() like the built-in visual. If you guys have any idea, i really need it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2025 02:08:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Power-BI-visual-date-picker-slicer-not-work-with/m-p/4889180#M12960</guid>
      <dc:creator>lulalagulu</dc:creator>
      <dc:date>2025-12-01T02:08:34Z</dc:date>
    </item>
  </channel>
</rss>

