<?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 Create a virual table in which a column expression can be filter by a date slicer in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-virual-table-in-which-a-column-expression-can-be-filter/m-p/3194050#M157044</link>
    <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I am repharsing a previous query with the hope of getting some help.&lt;BR /&gt;&lt;SPAN&gt;In the Employee Data table I have a EmpID, Date of Hire, and Date of Termination columns. The relationship between 'Employee Data'[Date of Hire] and 'dimCalender'[date] is active, the relationship between 'Employee Data'[Date of Termination] and 'dimCalender'[date] is inactive.&lt;BR /&gt;&lt;BR /&gt;I want to create a virtual table with columns for employee ID, tenure, and tenure category. I want this table to be filtered by a date slicer and the tenure category in the virtual table to be added to the x-axis of a visual.&amp;nbsp;The issue I am having is that the "Tenure" column of the virtual table is not filtering when the date slicer is adjusted.&lt;BR /&gt;&lt;BR /&gt;Here are the measures I am using:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Tenure Measure (Filtered) =
VAR StartDate =
    CALCULATE ( MIN ( DimCalendar[Date] ) )
VAR EndDate =
    MAX ( DimCalendar[Date] )
RETURN
    SUMX (
        FILTER (
            'Employee Data',
            'Employee Data'[Date of Hire] &amp;lt;= EndDate
                &amp;amp;&amp;amp; (
                    ISBLANK ( 'Employee Data'[Date of Termination] )
                        || 'Employee Data'[Date of Termination] &amp;gt;= StartDate
                )
        ),
        DATEDIFF (
            'Employee Data'[Date of Hire],
            IF (
                (
                    ISBLANK ( 'Employee Data'[Date of Termination] )
                        || 'Employee Data'[Date of Termination] &amp;gt;= EndDate
                ),
                EndDate,
                'Employee Data'[Date of Termination]
            ),
            DAY
        ) / 365.2425
    )

Tenure Category = 
SWITCH(
    TRUE(),
    [Tenure Measure (Filtered)] &amp;lt; 0.5 , "6 months",
    [Tenure Measure (Filtered)] &amp;lt; 1, "1 year",
    [Tenure Measure (Filtered)] &amp;lt; 2, "2 years",
    [Tenure Measure (Filtered)] &amp;lt; 5, "5 years",
    [Tenure Measure (Filtered)] &amp;lt; 10, "10 years",
    [Tenure Measure (Filtered)] &amp;gt;= 10, "10 years or more",
    BLANK()
)

Tenure Bins Table =
SELECTCOLUMNS (
    FILTER (
        'Employee Data',
        'Employee Data'[Date of Hire] &amp;lt;= MAX ( dimCalendar[Date] )
            &amp;amp;&amp;amp; (
                ISBLANK ( 'Employee Data'[Date of Termination] )
                    || 'Employee Data'[Date of Termination] &amp;gt; MAX ( dimCalendar[Date] )
            )
    ),
    "Employee ID", 'Employee Data'[EmpID],
    "Tenure",
        CALCULATE (
            [Tenure Measure (Filtered)],
            ALLEXCEPT ( 'Employee Data', 'Employee Data'[EmpID] )
        ),
    "Tenure Category",
        CALCULATE (
            [Tenure Category],
            ALLEXCEPT ( 'Employee Data', 'Employee Data'[EmpID] )
        )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!Aq7b9DmKneZwkWiKx1UipBIvXZZ-?e=yduneP" target="_blank" rel="noopener"&gt;Dataset&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for any help in advance,&lt;BR /&gt;&lt;BR /&gt;Ronan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Apr 2023 15:49:22 GMT</pubDate>
    <dc:creator>ronan_b</dc:creator>
    <dc:date>2023-04-18T15:49:22Z</dc:date>
    <item>
      <title>Create a virual table in which a column expression can be filter by a date slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-virual-table-in-which-a-column-expression-can-be-filter/m-p/3194050#M157044</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I am repharsing a previous query with the hope of getting some help.&lt;BR /&gt;&lt;SPAN&gt;In the Employee Data table I have a EmpID, Date of Hire, and Date of Termination columns. The relationship between 'Employee Data'[Date of Hire] and 'dimCalender'[date] is active, the relationship between 'Employee Data'[Date of Termination] and 'dimCalender'[date] is inactive.&lt;BR /&gt;&lt;BR /&gt;I want to create a virtual table with columns for employee ID, tenure, and tenure category. I want this table to be filtered by a date slicer and the tenure category in the virtual table to be added to the x-axis of a visual.&amp;nbsp;The issue I am having is that the "Tenure" column of the virtual table is not filtering when the date slicer is adjusted.&lt;BR /&gt;&lt;BR /&gt;Here are the measures I am using:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Tenure Measure (Filtered) =
VAR StartDate =
    CALCULATE ( MIN ( DimCalendar[Date] ) )
VAR EndDate =
    MAX ( DimCalendar[Date] )
RETURN
    SUMX (
        FILTER (
            'Employee Data',
            'Employee Data'[Date of Hire] &amp;lt;= EndDate
                &amp;amp;&amp;amp; (
                    ISBLANK ( 'Employee Data'[Date of Termination] )
                        || 'Employee Data'[Date of Termination] &amp;gt;= StartDate
                )
        ),
        DATEDIFF (
            'Employee Data'[Date of Hire],
            IF (
                (
                    ISBLANK ( 'Employee Data'[Date of Termination] )
                        || 'Employee Data'[Date of Termination] &amp;gt;= EndDate
                ),
                EndDate,
                'Employee Data'[Date of Termination]
            ),
            DAY
        ) / 365.2425
    )

Tenure Category = 
SWITCH(
    TRUE(),
    [Tenure Measure (Filtered)] &amp;lt; 0.5 , "6 months",
    [Tenure Measure (Filtered)] &amp;lt; 1, "1 year",
    [Tenure Measure (Filtered)] &amp;lt; 2, "2 years",
    [Tenure Measure (Filtered)] &amp;lt; 5, "5 years",
    [Tenure Measure (Filtered)] &amp;lt; 10, "10 years",
    [Tenure Measure (Filtered)] &amp;gt;= 10, "10 years or more",
    BLANK()
)

Tenure Bins Table =
SELECTCOLUMNS (
    FILTER (
        'Employee Data',
        'Employee Data'[Date of Hire] &amp;lt;= MAX ( dimCalendar[Date] )
            &amp;amp;&amp;amp; (
                ISBLANK ( 'Employee Data'[Date of Termination] )
                    || 'Employee Data'[Date of Termination] &amp;gt; MAX ( dimCalendar[Date] )
            )
    ),
    "Employee ID", 'Employee Data'[EmpID],
    "Tenure",
        CALCULATE (
            [Tenure Measure (Filtered)],
            ALLEXCEPT ( 'Employee Data', 'Employee Data'[EmpID] )
        ),
    "Tenure Category",
        CALCULATE (
            [Tenure Category],
            ALLEXCEPT ( 'Employee Data', 'Employee Data'[EmpID] )
        )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!Aq7b9DmKneZwkWiKx1UipBIvXZZ-?e=yduneP" target="_blank" rel="noopener"&gt;Dataset&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for any help in advance,&lt;BR /&gt;&lt;BR /&gt;Ronan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 15:49:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-virual-table-in-which-a-column-expression-can-be-filter/m-p/3194050#M157044</guid>
      <dc:creator>ronan_b</dc:creator>
      <dc:date>2023-04-18T15:49:22Z</dc:date>
    </item>
  </channel>
</rss>

