<?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: SELECTEDVALUE inside table constructor in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4239201#M167724</link>
    <description>&lt;P&gt;Thanks for the sample file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's something going on here that I don't understand and in my digging I found this related result that I'm leaving as a note for my future self:&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;EVALUATE
SUMMARIZECOLUMNS (
    Category[ItmsGrpNam],
    TREATAS ( { "Viaka" }, 'Categoria Obj 1'[ItmsGrpNam] ),
    TREATAS ( { "Activos" }, Category[ItmsGrpNam] ),
    "V1", /*Returns Viaka*/
        CALCULATE (
            MAX ( Category[ItmsGrpNam] ),
            KEEPFILTERS (
                Category[ItmsGrpNam] = MAX ( 'Categoria Obj 1'[ItmsGrpNam] )
            )
        ),
    "V2", /*Returns Blank*/
        CALCULATE (
            MAX ( Category[ItmsGrpNam] ),
            KEEPFILTERS (
                FILTER (
                    ALL ( Category[ItmsGrpNam] ),
                    Category[ItmsGrpNam] = MAX ( 'Categoria Obj 1'[ItmsGrpNam] )
                )
            )
        ),
    "V3", /*Returns Blank*/
        CALCULATE (
            MAX ( Category[ItmsGrpNam] ),
            KEEPFILTERS (
                Category[ItmsGrpNam] = VALUES ( 'Categoria Obj 1'[ItmsGrpNam] )
            )
        )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;I'm not sure why V1 doesn't match V2 or V3.&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="41" data-lia-user-login="marcorusso" class="lia-mention lia-mention-user"&gt;marcorusso&lt;/a&gt;, can you help explain what's going on here?&lt;/P&gt;</description>
    <pubDate>Fri, 11 Oct 2024 17:37:43 GMT</pubDate>
    <dc:creator>AlexisOlson</dc:creator>
    <dc:date>2024-10-11T17:37:43Z</dc:date>
    <item>
      <title>SELECTEDVALUE inside table constructor</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4237429#M167610</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following measure inside a filter context where the only selected value for column&amp;nbsp;'ParameterTable'[ItmNam] is "A" (in fact it's a parameter table):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE(
    COUNTROWS('Table'),
    'Table'[ItemName] IN {SELECTEDVALUE('ParameterTable'[ItmNam])}
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the measure is not counting the rows in table 'Table' where ItemName = "A".&lt;/P&gt;&lt;P&gt;If I change the measure as follows, it works fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE(
    COUNTROWS('Table'),
    'Table'[ItemName] IN {"A"}
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why SELECTEDVALUE doesn't works inside a table constreuctor?&lt;/P&gt;&lt;P&gt;Where is this limitation written or explained?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I don't need a workaround (variables can solve it), I need the conseptual explanation or documentation plese.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="41" data-lia-user-login="marcorusso" class="lia-mention lia-mention-user"&gt;marcorusso&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 17:42:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4237429#M167610</guid>
      <dc:creator>juan_pablo</dc:creator>
      <dc:date>2024-10-10T17:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: SELECTEDVALUE inside table constructor</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4237467#M167613</link>
      <description>&lt;P&gt;If I recall correctly, SELECTEDVALUE() only will ever return a single value, and cannot return multiple values at once. What you should do is this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE(
    COUNTROWS(
        'Table'
    ),
    'Table'[Column1] IN ALLSELECTED(ParamTable[Column1])
)&lt;/LI-CODE&gt;&lt;P&gt;This will properly count all of the selected values from the Param table, hence ALLSELECTED() rather than SELECTEDVALUE().&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 18:08:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4237467#M167613</guid>
      <dc:creator>Alex_Sawdo</dc:creator>
      <dc:date>2024-10-10T18:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: SELECTEDVALUE inside table constructor</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4237506#M167617</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="390735" data-lia-user-login="Alex_Sawdo" class="lia-mention lia-mention-user"&gt;Alex_Sawdo&lt;/a&gt;, ALLSELECTED isn't necessarily what you want (though it might be in some cases).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd suggest one of the following instead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;CALCULATE (
    COUNTROWS ( 'Table' ),
    'Table'[ItemName] IN VALUES ( 'ParameterTable'[ItmNam] )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="php"&gt;CALCULATE (
    COUNTROWS ( 'Table' ),
    TREATAS ( VALUES ( 'ParameterTable'[ItmNam] ), 'Table'[ItemName] )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doesn't really answer OP's question though.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81266" data-lia-user-login="juan_pablo" class="lia-mention lia-mention-user"&gt;juan_pablo&lt;/a&gt;, in my testing, the first measure&amp;nbsp;&lt;EM&gt;does&lt;/EM&gt; do what you're expecting if a single parameter value is selected.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 18:46:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4237506#M167617</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2024-10-10T18:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: SELECTEDVALUE inside table constructor</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4237649#M167624</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;, thank you very much. It seems I oversimplified the example. There was a KEEPFILTERS involved. Attached is the original model, where you can see how differently these two measures behave:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Filter Table = 
CALCULATE(
    COUNTROWS('Item'),
    KEEPFILTERS('Category'[ItmsGrpNam] IN {SELECTEDVALUE('Categoria Obj 1'[ItmsGrpNam])})
)

vs

Filter Table OK = 
CALCULATE(
    COUNTROWS('Item'),
    KEEPFILTERS('Category'[ItmsGrpNam] IN {"Viaka"})
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why do they behave differently?&lt;/P&gt;&lt;P&gt;&lt;!-- StartFragment  --&gt;&lt;A href="https://uniontecolog-my.sharepoint.com/:u:/g/personal/jreyesv_ecolog_com_co/EbFuoNC5PClGtGrek9gNTk0BVxmOXblYMeeV_nEZu1RBVg?e=n9RQ9m" target="_blank"&gt;SELECTEDVALUE.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 21:35:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4237649#M167624</guid>
      <dc:creator>juan_pablo</dc:creator>
      <dc:date>2024-10-10T21:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: SELECTEDVALUE inside table constructor</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4239201#M167724</link>
      <description>&lt;P&gt;Thanks for the sample file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's something going on here that I don't understand and in my digging I found this related result that I'm leaving as a note for my future self:&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;EVALUATE
SUMMARIZECOLUMNS (
    Category[ItmsGrpNam],
    TREATAS ( { "Viaka" }, 'Categoria Obj 1'[ItmsGrpNam] ),
    TREATAS ( { "Activos" }, Category[ItmsGrpNam] ),
    "V1", /*Returns Viaka*/
        CALCULATE (
            MAX ( Category[ItmsGrpNam] ),
            KEEPFILTERS (
                Category[ItmsGrpNam] = MAX ( 'Categoria Obj 1'[ItmsGrpNam] )
            )
        ),
    "V2", /*Returns Blank*/
        CALCULATE (
            MAX ( Category[ItmsGrpNam] ),
            KEEPFILTERS (
                FILTER (
                    ALL ( Category[ItmsGrpNam] ),
                    Category[ItmsGrpNam] = MAX ( 'Categoria Obj 1'[ItmsGrpNam] )
                )
            )
        ),
    "V3", /*Returns Blank*/
        CALCULATE (
            MAX ( Category[ItmsGrpNam] ),
            KEEPFILTERS (
                Category[ItmsGrpNam] = VALUES ( 'Categoria Obj 1'[ItmsGrpNam] )
            )
        )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;I'm not sure why V1 doesn't match V2 or V3.&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="41" data-lia-user-login="marcorusso" class="lia-mention lia-mention-user"&gt;marcorusso&lt;/a&gt;, can you help explain what's going on here?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2024 17:37:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4239201#M167724</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2024-10-11T17:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: SELECTEDVALUE inside table constructor</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4239278#M167735</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;I got blank for the three columns. It could be that I'm using an updated version - try again with the October 2024 release when available, and let me know if you can still reproduce the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2024 20:13:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SELECTEDVALUE-inside-table-constructor/m-p/4239278#M167735</guid>
      <dc:creator>marcorusso</dc:creator>
      <dc:date>2024-10-11T20:13:02Z</dc:date>
    </item>
  </channel>
</rss>

