<?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: conditional based off of drop down slicer in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/conditional-based-off-of-drop-down-slicer/m-p/3689850#M143383</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="681154" data-lia-user-login="srpeters" class="lia-mention lia-mention-user"&gt;srpeters&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It seems that you are trying to create a measure that counts the number of employees hired or terminated in a given year, based on a slicer. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, your current measure is not working because you are using the VALUES function, which returns a table of distinct values, and comparing it with another table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;One possible solution is to use the SELECTEDVALUE function instead of the VALUES function.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; The SELECTEDVALUE function returns a single value from a table, or a default value if there are multiple values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; This way, you can compare a single value with another single value, and avoid the error.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here is an example of how you can modify your measure:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
    IF(
        SELECTEDVALUE(Table[DateOfHire].[Year], 0) = SELECTEDVALUE(Table[YearsHired/FiredForSlicer], 0), 
        COUNT(Table[DateOfHire].[Year]), 
        COUNT(Table[DateOfTermination].[Year]) 
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This measure will check if the selected year from the slicer matches the year of hire for each employee.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; If it does, it will count the number of employees hired in that year. If it does not, it will count the number of employees terminated in that year. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The default value of 0 is used to handle the case when there is no selection or multiple selections in the slicer.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/values-function-dax" target="_blank"&gt;VALUES function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/selectedvalue-function" target="_blank"&gt;SELECTEDVALUE function - DAX | Microsoft Learn&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Nono Chen&lt;/P&gt;
&lt;P&gt;If this &lt;STRONG&gt;&lt;EM&gt;post&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;helps, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Feb 2024 03:17:52 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-02-09T03:17:52Z</dc:date>
    <item>
      <title>conditional based off of drop down slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/conditional-based-off-of-drop-down-slicer/m-p/3688498#M143304</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a slicer that either represents someones hire date if still employed or their termination date if not.&amp;nbsp; I want the visuals to show all the employees who were hired on the year selected, even if they are no longer active. For this I need to count the amount of employees whos hire date was equal to the year selected, but this filter simply gives their hire date if they are currently employed, or their termination date if not. Because of this, for the card representing those hired on the date selected, it is counting those whos termination year is equal to the slicers year even if they were hired on a different year. Is there a way to change this DAX function to change the Hired card to show those hired on that year while also showing those terminated on the terminations card? I could just have a DAX that sees if their hire date is equal to the date selected like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Measure&lt;/SPAN&gt; &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;VALUES&lt;/SPAN&gt;&lt;SPAN&gt;(Table[DateOfHire]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Year]) == &lt;/SPAN&gt;&lt;SPAN&gt;Values&lt;/SPAN&gt;&lt;SPAN&gt;(Table[YearsHired/FiredForSlicer]), &lt;/SPAN&gt;&lt;SPAN&gt;COUNT&lt;/SPAN&gt;&lt;SPAN&gt;(Table[DateOfHire]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Year]), &lt;/SPAN&gt;&lt;SPAN&gt;COUNT&lt;/SPAN&gt;&lt;SPAN&gt;(Table[DateOfTermination]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Year]))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If I do this however, it syas "A table with multiple values was supplied where a single value was expected".&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 08 Feb 2024 14:54:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/conditional-based-off-of-drop-down-slicer/m-p/3688498#M143304</guid>
      <dc:creator>srpeters</dc:creator>
      <dc:date>2024-02-08T14:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: conditional based off of drop down slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/conditional-based-off-of-drop-down-slicer/m-p/3689850#M143383</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="681154" data-lia-user-login="srpeters" class="lia-mention lia-mention-user"&gt;srpeters&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It seems that you are trying to create a measure that counts the number of employees hired or terminated in a given year, based on a slicer. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, your current measure is not working because you are using the VALUES function, which returns a table of distinct values, and comparing it with another table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;One possible solution is to use the SELECTEDVALUE function instead of the VALUES function.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; The SELECTEDVALUE function returns a single value from a table, or a default value if there are multiple values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; This way, you can compare a single value with another single value, and avoid the error.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here is an example of how you can modify your measure:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
    IF(
        SELECTEDVALUE(Table[DateOfHire].[Year], 0) = SELECTEDVALUE(Table[YearsHired/FiredForSlicer], 0), 
        COUNT(Table[DateOfHire].[Year]), 
        COUNT(Table[DateOfTermination].[Year]) 
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This measure will check if the selected year from the slicer matches the year of hire for each employee.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; If it does, it will count the number of employees hired in that year. If it does not, it will count the number of employees terminated in that year. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The default value of 0 is used to handle the case when there is no selection or multiple selections in the slicer.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/values-function-dax" target="_blank"&gt;VALUES function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/selectedvalue-function" target="_blank"&gt;SELECTEDVALUE function - DAX | Microsoft Learn&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Nono Chen&lt;/P&gt;
&lt;P&gt;If this &lt;STRONG&gt;&lt;EM&gt;post&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;helps, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 03:17:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/conditional-based-off-of-drop-down-slicer/m-p/3689850#M143383</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-09T03:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: conditional based off of drop down slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/conditional-based-off-of-drop-down-slicer/m-p/3691142#M143427</link>
      <description>&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 14:22:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/conditional-based-off-of-drop-down-slicer/m-p/3691142#M143427</guid>
      <dc:creator>srpeters</dc:creator>
      <dc:date>2024-02-09T14:22:13Z</dc:date>
    </item>
  </channel>
</rss>

