<?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: Unable to use SELECTEDVALUE variable in DAX calculations in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-use-SELECTEDVALUE-variable-in-DAX-calculations/m-p/3857141#M150682</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="426215" data-lia-user-login="gmsamborn" class="lia-mention lia-mention-user"&gt;gmsamborn&lt;/a&gt;t Thanks a lot, for your efforts.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have following questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;1. Is it must to have a separate slicer table? Can I just use the Date table for slicer directly?&lt;BR /&gt;&lt;BR /&gt;2. In my dashboard, I would use the month slicer for other visuals as well. Since this is a different application of slicer, I can't keep the slicer interaction enabled with this visualization. I want to use the selected slicer month value indirectly using Dax.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;In your solution, when I disable the interaction of slicer with visualization, nothing works and it shows all the data. Can we somehow make it work while keeping the interaction disabled?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 21 Apr 2024 21:17:20 GMT</pubDate>
    <dc:creator>Gondal-756</dc:creator>
    <dc:date>2024-04-21T21:17:20Z</dc:date>
    <item>
      <title>Unable to use SELECTEDVALUE variable in DAX calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-use-SELECTEDVALUE-variable-in-DAX-calculations/m-p/3856923#M150673</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I have a DAX calculation where I use a slectedvalue()&amp;nbsp; from a month slicer.&lt;BR /&gt;If I just return the selectedvalue() itself,&amp;nbsp; it returns the selected month from slicer, but when I try to use this &lt;STRONG&gt;selectedvalue&amp;nbsp;&lt;/STRONG&gt;in a DAX condition, it never works.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;My Data:&lt;BR /&gt;&lt;BR /&gt;1. Calendar Table :&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;2. Sales Table:&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;What I Want:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;Sum the sales for each month , but only upto the &lt;STRONG&gt;selected month (in month slicer).&lt;/STRONG&gt;&lt;BR /&gt;For example if I select February, I should see total sales of January and February only.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;My current DAX Code :&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sales by Selected Month = 
VAR SelectedMonth = SLECTEDVALUE('Calendar'[date].[Month])

RETURN
CALCULATE(
           SUM('Table'[Sales(USD)]), 
           FILTER(
                 'Table',
                  'Table'[date].[Month] &amp;lt;= SelectedMonth
                  )
 )   &lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;In the above Dax code, in the calculate function instead of using &lt;STRONG&gt;SlectedMonth&lt;/STRONG&gt; variable, if I use a static month number like 2, it works but when I use the variable it returns the sum of sales for the whole year.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@all&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2024 16:17:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-use-SELECTEDVALUE-variable-in-DAX-calculations/m-p/3856923#M150673</guid>
      <dc:creator>Gondal-756</dc:creator>
      <dc:date>2024-04-21T16:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to use SELECTEDVALUE variable in DAX calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-use-SELECTEDVALUE-variable-in-DAX-calculations/m-p/3857046#M150676</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="729154" data-lia-user-login="Gondal-756" class="lia-mention lia-mention-user"&gt;Gondal-756&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my solution, I used a date table as well as a disconnected slicer table.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Create a well-formed Date table.&amp;nbsp; The date table you listed &lt;STRONG&gt;isn't a date table&lt;/STRONG&gt;.&amp;nbsp;&amp;nbsp;(Even if you aren't using time intelligence calculations, it is a best practice to use a well-formed date table.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;In order to use any time intelligence calculation, you need a well-formed date table. The&amp;nbsp;Date&amp;nbsp;table must satisfy the following requirements:&lt;/EM&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;All dates need to be present for the years required. The&amp;nbsp;Date&amp;nbsp;table must always start on January 1 and end on December 31, including all the days in this range.&amp;nbsp;&lt;/EM&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;There needs to be a column with a&amp;nbsp;DateTime&amp;nbsp;or&amp;nbsp;Date&amp;nbsp;data type containing unique values. This column is usually called&amp;nbsp;Date. Even though the&amp;nbsp;Date&amp;nbsp;column is often used to define relationships with other tables, this is not required. Still, the&amp;nbsp;Date&amp;nbsp;column must contain unique values and should be referenced by the Mark as Date Table feature. In case the column also contains a time part, no time should be used – for example, the time should always be 12:00 am.&lt;/EM&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;The&amp;nbsp;Date&amp;nbsp;table must be marked as a date table in the model, in case the relationship between the&amp;nbsp;Date&amp;nbsp;table and any other table is not based on the&amp;nbsp;Date.&lt;/EM&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;2. Make sure your ‘Sales’[Date] has a Date data-type, not DateTime.&amp;nbsp; If you need the time portion, duplicate the DateTime column and change to Date.&amp;nbsp; Rename the columns accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Create a 1:* (one direction) relationship between ‘Date’[Date] and ‘Sales’[Date].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. Create a table that is a list of [MMM-YY] and [YearMonth] from ‘Date’ to be used in a slicer.&amp;nbsp; ( [Month] and [MonthNo] could be used if you prefer.&amp;nbsp; My preference would be to handle multiple years.)&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;SlicerMonths = 
    SUMMARIZE(
        'Date',
        'Date'[MMM-YY],
        'Date'[YearMonth]
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. Create the following measure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales by Selected Month = 
VAR _SelectedMonth = MAX( 'SlicerMonths'[YearMonth] )
RETURN
    CALCULATE(
        SUM( 'Sales'[Sales(USD)] ),
        FILTER(
            ALL( 'Date'[YearMonth] ),
            'Date'[YearMonth] &amp;lt;= _SelectedMonth
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if you have any questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AnF6rI36HAVkhYZmapx9b-UX2PXucQ?e=z2yxdO" target="_blank" rel="noopener"&gt;Gondal-756.pbix&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2024 19:20:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-use-SELECTEDVALUE-variable-in-DAX-calculations/m-p/3857046#M150676</guid>
      <dc:creator>gmsamborn</dc:creator>
      <dc:date>2024-04-21T19:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to use SELECTEDVALUE variable in DAX calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-use-SELECTEDVALUE-variable-in-DAX-calculations/m-p/3857141#M150682</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="426215" data-lia-user-login="gmsamborn" class="lia-mention lia-mention-user"&gt;gmsamborn&lt;/a&gt;t Thanks a lot, for your efforts.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have following questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;1. Is it must to have a separate slicer table? Can I just use the Date table for slicer directly?&lt;BR /&gt;&lt;BR /&gt;2. In my dashboard, I would use the month slicer for other visuals as well. Since this is a different application of slicer, I can't keep the slicer interaction enabled with this visualization. I want to use the selected slicer month value indirectly using Dax.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;In your solution, when I disable the interaction of slicer with visualization, nothing works and it shows all the data. Can we somehow make it work while keeping the interaction disabled?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2024 21:17:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-use-SELECTEDVALUE-variable-in-DAX-calculations/m-p/3857141#M150682</guid>
      <dc:creator>Gondal-756</dc:creator>
      <dc:date>2024-04-21T21:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to use SELECTEDVALUE variable in DAX calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-use-SELECTEDVALUE-variable-in-DAX-calculations/m-p/3860215#M150785</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="729154" data-lia-user-login="Gondal-756" class="lia-mention lia-mention-user"&gt;Gondal-756&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It wasn't easy to make the slicer based on the calendar table AND have the visual display rows that AREN'T from the selected month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I based the rows on the values in the table that was originally set up as a disconnected slicer. (renamed to 'MonthList')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The measure is as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;xInnerCalc = 
VAR _Dcurr = MAX( 'Date'[YearMonth] )
VAR _Curr = SELECTEDVALUE( 'MonthList'[YearMonth] )
VAR _Table =
    FILTER(
        SUMMARIZE(
            ALL( 'Date' ),
            'Date'[YearMonth],
            "__Amt",
                SUM( 'Sales'[Sales(USD)] )
        ),
        [YearMonth] = _Curr
    )
VAR _Total =
    SUMX(
        _Table,
        [__Amt]
    )
VAR _Result =
    IF(
        _Curr &amp;lt;= _Dcurr,
        _Total
    )
RETURN
    _Result
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To handle the totals, I created the following measure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;xSales = 
    SUMX(
        'MonthList',
        [xInnerCalc]
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AnF6rI36HAVkhYZpDVwg06Sou_sXqA?e=Q8jRl0" target="_blank" rel="noopener"&gt;Gondal-756 - 2.pbix&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 22:02:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-use-SELECTEDVALUE-variable-in-DAX-calculations/m-p/3860215#M150785</guid>
      <dc:creator>gmsamborn</dc:creator>
      <dc:date>2024-04-22T22:02:32Z</dc:date>
    </item>
  </channel>
</rss>

