<?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: Notebook with sempy - giving a date range for filters in Data Science</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3625876#M9</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="456480" data-lia-user-login="anandfarmers" class="lia-mention lia-mention-user"&gt;anandfarmers&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Thanks for using Fabric Community.&lt;BR /&gt;Can you please check if below code works for you, it can get data filter by month and year.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import sempy.fabric as fabric

filters = {
    "State[Region]": ["East", "Central"],
    "State[State]": ["FLORIDA", "NEW YORK"],
    "Calendar[Month]": ["Aug"],
    "Calendar[Year]": [2013]
}

df_measure = fabric.evaluate_measure(
    "Customer Profitability Sample",
    "Total Revenue",
    ["Customer[State]", "Calendar[Date]", "Calendar[Month]", "Calendar[Year]"],
    filters=filters)

df_measure&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Hope this is helpful. Please let me know incase of further queries.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jan 2024 10:50:40 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-01-09T10:50:40Z</dc:date>
    <item>
      <title>Notebook with sempy - giving a date range for filters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3624361#M8</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have sempy working in Notebook and can pass filters as explained in Microsoft documentation.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;filters = {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"TestData[Prodct]"&lt;/SPAN&gt;&lt;SPAN&gt;: [&lt;/SPAN&gt;&lt;SPAN&gt;"ABC1"&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;#,"State[State]": ["FLORIDA", "NEW YORK"]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;df_measure = fabric.evaluate_measure(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;# Dataset name&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"FabricTraining-NewModelForUsers"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;# Measure&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; ,&lt;/SPAN&gt;&lt;SPAN&gt;"Sum of Price"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;# Group By&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; ,[&lt;/SPAN&gt;&lt;SPAN&gt;"TestData[Prodct]"&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;# Filters&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; ,filters=filters&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;df_measure&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The above example work fine.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;My question :&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;How can I pass a date range using this filters dictionary technique?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;e.g. For Jan 2024 dates - do I need to list each date?&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;That would make it dificult if the date range spans starting part of a month and ending part of another month.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Any&amp;nbsp; suggestions?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Jan 2024 03:43:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3624361#M8</guid>
      <dc:creator>anandfarmers</dc:creator>
      <dc:date>2024-01-09T03:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook with sempy - giving a date range for filters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3625876#M9</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="456480" data-lia-user-login="anandfarmers" class="lia-mention lia-mention-user"&gt;anandfarmers&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Thanks for using Fabric Community.&lt;BR /&gt;Can you please check if below code works for you, it can get data filter by month and year.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import sempy.fabric as fabric

filters = {
    "State[Region]": ["East", "Central"],
    "State[State]": ["FLORIDA", "NEW YORK"],
    "Calendar[Month]": ["Aug"],
    "Calendar[Year]": [2013]
}

df_measure = fabric.evaluate_measure(
    "Customer Profitability Sample",
    "Total Revenue",
    ["Customer[State]", "Calendar[Date]", "Calendar[Month]", "Calendar[Year]"],
    filters=filters)

df_measure&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Hope this is helpful. Please let me know incase of further queries.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 10:50:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3625876#M9</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-09T10:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook with sempy - giving a date range for filters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3627854#M10</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;I understand we can give month name.&lt;/P&gt;&lt;P&gt;But as I mentioned, if the date range starts part of a month and ends part of the same month or another&amp;nbsp; month then we have to list each date. e.g. 2nd of Jan 2023 to 5th of March 2023.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand how to give such date ranges.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 22:27:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3627854#M10</guid>
      <dc:creator>anandfarmers</dc:creator>
      <dc:date>2024-01-09T22:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook with sempy - giving a date range for filters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3636226#M11</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="456480" data-lia-user-login="anandfarmers" class="lia-mention lia-mention-user"&gt;anandfarmers&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Apologies for the delay in reply from our side.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;fabric.evaluate_measure &lt;/STRONG&gt;has&amp;nbsp;the limitation of the filter that only suppors the '&lt;STRONG&gt;in'&lt;/STRONG&gt; operator.&lt;BR /&gt;If you are looking towards range operation then i recommed to use&amp;nbsp;&lt;STRONG&gt;fabric.evaluate_dax&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;.&lt;BR /&gt;&lt;BR /&gt;For eg:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import sempy.fabric as fabric

df_dax = fabric.evaluate_dax(
    "Customer Profitability Sample",
    """
    EVALUATE SUMMARIZECOLUMNS(
        'State'[Region],
        'Calendar'[Year],
        'Calendar'[Month],
        'State'[State],
        FILTER('Calendar', 'Calendar'[Year] &amp;gt;= 2009 &amp;amp;&amp;amp; 'Calendar'[Year] &amp;lt;= 2011),
        )
    """)

df_dax
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Inorder to get some idea please refer below link,&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-science/read-write-power-bi" target="_blank"&gt;Read data from semantic models and write data that semantic models can consume - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/filter-function-dax" target="_blank"&gt;FILTER function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this is helpful. Please let me know incase of further queries.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 15:38:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3636226#M11</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-12T15:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook with sempy - giving a date range for filters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3637962#M12</link>
      <description>&lt;P&gt;Thank you for the reply.&lt;/P&gt;&lt;P&gt;It calrifies different use cases of the functions.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 01:49:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3637962#M12</guid>
      <dc:creator>anandfarmers</dc:creator>
      <dc:date>2024-01-15T01:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook with sempy - giving a date range for filters</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3640081#M13</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="456480" data-lia-user-login="anandfarmers" class="lia-mention lia-mention-user"&gt;anandfarmers&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Glad to know that your query got resolved. Please continue using Fabric Community for your further queries.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 04:27:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Notebook-with-sempy-giving-a-date-range-for-filters/m-p/3640081#M13</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-16T04:27:19Z</dc:date>
    </item>
  </channel>
</rss>

