<?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: Get column values from table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/761881#M3232</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="17551" data-lia-user-login="SteveCampbell" class="lia-mention lia-mention-user"&gt;SteveCampbell&lt;/a&gt;&lt;/P&gt;&lt;P&gt;thanks, the first example seems what I was looking for, but now the error appears:&amp;nbsp;&lt;/P&gt;&lt;P&gt;"The function expects a table expression for argument '2', but a string or numeric expression was used."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I use your example without condition on Sales[Store], there are no errors. So, as I can judge, the point is about using IN here.&lt;/P&gt;&lt;P&gt;Do you have an idea how to fix it?&lt;/P&gt;</description>
    <pubDate>Thu, 08 Aug 2019 15:05:36 GMT</pubDate>
    <dc:creator>Seven440</dc:creator>
    <dc:date>2019-08-08T15:05:36Z</dc:date>
    <item>
      <title>Get column values from table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/760236#M3159</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The task seems simple, but search in forums and DAX guide didn't help me.&lt;/P&gt;&lt;P&gt;There is the only table &lt;STRONG&gt;Sales&lt;/STRONG&gt; with several columns (Item, Store, Area, Month, Flag1, Flag2, Value).&lt;/P&gt;&lt;P&gt;I try to add calculated column with next expression:&lt;/P&gt;&lt;PRE&gt;=SUMX(
	FILTER(Sales;
		EARLIER(Sales[Month]) = Sales[Month] &amp;amp;&amp;amp;
		[Flag1] = "No" &amp;amp;&amp;amp;

		Sales[Store] in distinct(SELECTCOLUMNS(
						FILTER(Sales;
							EARLIER(Sales[Month]) = Sales[Month]&amp;amp;&amp;amp; 
							EARLIER(Sales[Area]) = Sales[Area] &amp;amp;&amp;amp; 
							EARLIER(Sales[Item]) = Sales[Item] &amp;amp;&amp;amp; 
							Sales[Flag2] = 1);
							"Store";Sales[Store])
					
				)
		);
	Sales[Value])&lt;/PRE&gt;&lt;P&gt;The problem is with condition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Sales[Store] in distinct(SELECTCOLUMNS(
...&lt;/PRE&gt;&lt;P&gt;I can't find a function instead of SELECTCOLUMNS to get a list of values in Store column.&lt;/P&gt;&lt;P&gt;Further, I planned to get unique values in the column (with DISTINCT) to make a list of values and use it to check Sales[Store] (with IN).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 09:54:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/760236#M3159</guid>
      <dc:creator>Seven440</dc:creator>
      <dc:date>2019-08-07T09:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get column values from table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/761170#M3206</link>
      <description>&lt;P&gt;I'm not sure quite the desired output, but it looks like you're trying to say:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sum &lt;FONT color="#FF0000"&gt;Sales[Value]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Where &lt;FONT color="#FF0000"&gt;month&lt;/FONT&gt; is the current row month&lt;/P&gt;&lt;P&gt;and &lt;FONT color="#FF0000"&gt;Flag1&lt;/FONT&gt; = "No"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the current &lt;FONT color="#FF0000"&gt;store&lt;/FONT&gt;, &lt;FONT color="#FF0000"&gt;month, area&lt;/FONT&gt; and item has to exist in the table with &lt;FONT color="#FF0000"&gt;Flag2&lt;/FONT&gt; = 1 ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If so, I rewrote a little to optimize:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;=
VAR _month = Sales[Month]
VAR _area = Sales[Area]
VAR _item = Sales[Item]
VAR _store = Sales[Store]
RETURN
    CALCULATE (
        SUM ( Sales[Value] ),
        FILTER (
            Sales,
            Sales[Month] = _Month
                &amp;amp;&amp;amp; [Flag1] = "No"
                &amp;amp;&amp;amp; Sales[Store]
                    IN CALCULATETABLE (
                        VALUES ( Sales[Store] ),
                        Sales[Month] = _month,
                        Sales[Area] = _area,
                        Sales[Item] = _item,
                        Sales[Flag2] = 1
                    )
        )
    )&lt;/PRE&gt;&lt;P&gt;Right now, it sums the store only if that record has any value where&amp;nbsp;&lt;FONT color="#FF0000"&gt;store&lt;/FONT&gt;, &lt;FONT color="#FF0000"&gt;month, area&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;exists&lt;/STRONG&gt; in the table with &lt;FONT color="#FF0000"&gt;Flag2&lt;/FONT&gt; = 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you actually wanted:&lt;/P&gt;&lt;P&gt;Sum &lt;FONT color="#FF0000"&gt;Sales[Value]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Where &lt;FONT color="#FF0000"&gt;month&lt;/FONT&gt; is the current row month&lt;/P&gt;&lt;P&gt;and &lt;FONT color="#FF0000"&gt;Flag1&lt;/FONT&gt; = "No"&lt;/P&gt;&lt;P&gt;and the current row&amp;nbsp;&lt;FONT color="#FF0000"&gt;store&lt;/FONT&gt;,&lt;/P&gt;&lt;P&gt;and the current row&amp;nbsp;&lt;FONT color="#FF0000"&gt;month,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;and the current row&lt;/FONT&gt; area&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&lt;FONT color="#FF0000"&gt;Flag2&lt;/FONT&gt; = 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then:&lt;/P&gt;&lt;PRE&gt;	
=
VAR _month = Sales[Month]
VAR _area = Sales[Area]
VAR _item = Sales[Item]
VAR _store = Sales[Store]
RETURN
    CALCULATE (
        SUM ( Sales[Value] )
			,Sales[Month] = _Month
            ,[Flag1] = "No"
			
		,FILTER (
            Sales
				Sales[Store] =_store,
                Sales[Month] = _month,
                Sales[Area] = _area,
                Sales[Item] = _item,
                Sales[Flag2] = 1
                    )
        )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Love hearing about Power BI tips, jobs and news?&lt;BR /&gt;I love to share about these - connect with me!&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.linkedin.com/in/stevencampbellmilwaukee" target="_blank" rel="noopener"&gt;&lt;U&gt;&lt;FONT color="#000000"&gt;Stay up to date on&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&lt;/U&gt;&lt;img /&gt;&lt;/A&gt;&lt;A href="https://www.powerbi.tips" target="_blank" rel="noopener"&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;Read my blogs on&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;img /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Remember to spread knowledge in the community when you can!&amp;nbsp;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 15:28:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/761170#M3206</guid>
      <dc:creator>SteveCampbell</dc:creator>
      <dc:date>2019-08-08T15:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get column values from table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/761881#M3232</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="17551" data-lia-user-login="SteveCampbell" class="lia-mention lia-mention-user"&gt;SteveCampbell&lt;/a&gt;&lt;/P&gt;&lt;P&gt;thanks, the first example seems what I was looking for, but now the error appears:&amp;nbsp;&lt;/P&gt;&lt;P&gt;"The function expects a table expression for argument '2', but a string or numeric expression was used."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I use your example without condition on Sales[Store], there are no errors. So, as I can judge, the point is about using IN here.&lt;/P&gt;&lt;P&gt;Do you have an idea how to fix it?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 15:05:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/761881#M3232</guid>
      <dc:creator>Seven440</dc:creator>
      <dc:date>2019-08-08T15:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get column values from table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/761901#M3234</link>
      <description>&lt;P&gt;yep, made an error - should have been CALCULATETABLE not CALCULATE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Updated the code, try now&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 15:28:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/761901#M3234</guid>
      <dc:creator>SteveCampbell</dc:creator>
      <dc:date>2019-08-08T15:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Get column values from table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/763863#M3310</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="17551" data-lia-user-login="SteveCampbell" class="lia-mention lia-mention-user"&gt;SteveCampbell&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the next error appears:&lt;/P&gt;&lt;P&gt;A circular dependency was detected: 'Sales'[Filtered_value],'Sales'[Filtered_value],'Sales'[Filtered_value].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Sales'[Filtered_value] is the resulting column (where I use the updated formula).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 07:07:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-column-values-from-table/m-p/763863#M3310</guid>
      <dc:creator>Seven440</dc:creator>
      <dc:date>2019-08-12T07:07:09Z</dc:date>
    </item>
  </channel>
</rss>

