<?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: How to loop through a list and use the items as filter values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286036#M122172</link>
    <description>&lt;P&gt;Calculated tables are only calculated during data load or refresh, so they don't pay any attention to slicers. If you want something to react to slicers dynamically you will need to use a measure instead.&lt;/P&gt;
&lt;P&gt;You can store a table in a variable inside a measure, and then use that as a filter for any calculations you need to perform.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2023 13:32:31 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2023-06-15T13:32:31Z</dc:date>
    <item>
      <title>How to loop through a list and use the items as filter values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3285792#M122153</link>
      <description>&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;I am trying to create a calculated table that contains valid employees based on a selection of dates from a slicer. Unfortunately, I don't know how to iterate through the date list. I am using the Dates and Employees tables as shown below. The first table shows three selected dates as in a slicer. The third table shows the expected table containing all employees where the selected dates are between Validfrom and Validto.&lt;BR /&gt;&lt;BR /&gt;Date Table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Employee Table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Expected calculated Table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;I have tried something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CalculatedTable =
VAR Dates =
    ALLSELECTED ( Dates[Date] )
RETURN
    CALCULATETABLE (
        Employee;
        Dates[Date] &amp;gt;= Employee[ValidFrom]
            &amp;amp;&amp;amp; Dates[Date] &amp;lt;= Employee[Validto]
    )&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Can you please help how to do this in DAX. Thanks a lot&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 11:16:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3285792#M122153</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-15T11:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through a list and use the items as filter values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286036#M122172</link>
      <description>&lt;P&gt;Calculated tables are only calculated during data load or refresh, so they don't pay any attention to slicers. If you want something to react to slicers dynamically you will need to use a measure instead.&lt;/P&gt;
&lt;P&gt;You can store a table in a variable inside a measure, and then use that as a filter for any calculations you need to perform.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 13:32:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286036#M122172</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-06-15T13:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through a list and use the items as filter values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286150#M122181</link>
      <description>&lt;P&gt;Hi&amp;nbsp; john75,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you provide a sample of what that would look like?&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 14:30:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286150#M122181</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-15T14:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through a list and use the items as filter values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286225#M122188</link>
      <description>&lt;LI-CODE lang="markup"&gt;Dummy Measure =
VAR DatesAndEmployees =
    GENERATE (
        ALLSELECTED ( 'Date'[Date] ),
        SELECTCOLUMNS (
            FILTER (
                Employees,
                Employees[Valid from] &amp;lt;= 'Date'[Date]
                    &amp;amp;&amp;amp; (
                        ISBLANK ( Employees[Valid to] )
                            || Employees[Valid to] &amp;gt;= 'Date'[Date]
                    )
            ),
            Employees[Employee ID],
            Employees[Name]
        )
    )
VAR Result =
    CALCULATE ( DISTINCTCOUNT ( Employees[Employee ID] ), DatesAndEmployees )
RETURN
    Result
&lt;/LI-CODE&gt;
&lt;P&gt;The first variable generates the table you wanted to build. Not sure what you wanted to use it for, but this example counts the number of employees who were valid on any of the given dates.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 15:02:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286225#M122188</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-06-15T15:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through a list and use the items as filter values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286361#M122195</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanks for your reply.&amp;nbsp;&lt;BR /&gt;Is it possible to return the filtered table "DatesAndEmployees" and use it as a table in a visual (table, matrix) in Power BI?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 15:41:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286361#M122195</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-15T15:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through a list and use the items as filter values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286390#M122198</link>
      <description>&lt;P&gt;No, I'm afraid not. If you wanted to list the employees you would need to create a measure like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Dummy Measure =
VAR DatesAndEmployees =
    GENERATE (
        ALLSELECTED ( 'Date'[Date] ),
        SELECTCOLUMNS (
            FILTER (
                Employees,
                Employees[Valid from] &amp;lt;= 'Date'[Date]
                    &amp;amp;&amp;amp; (
                        ISBLANK ( Employees[Valid to] )
                            || Employees[Valid to] &amp;gt;= 'Date'[Date]
                    )
            ),
            Employees[Employee ID],
            Employees[Name]
        )
    )
VAR Result =
    IF (
        SELECTEDVALUE ( Employees[Employee ID] )
            IN CALCULATE (
                VALUES ( Employees[Employee ID] ),
                KEEPFILTERS ( DatesAndEmployees )
            ),
        1
    )
RETURN
    Result
&lt;/LI-CODE&gt;
&lt;P&gt;and use that as a filter on the visual to only show when the value is 1.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 16:00:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-loop-through-a-list-and-use-the-items-as-filter-values/m-p/3286390#M122198</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-06-15T16:00:14Z</dc:date>
    </item>
  </channel>
</rss>

