<?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: SUMMARIZECOLUMNS produces an error using as a virtual table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMMARIZECOLUMNS-produces-an-error-using-as-a-virtual-table/m-p/1757326#M36713</link>
    <description>&lt;P&gt;Hi, sorry for the late response.&lt;/P&gt;&lt;P&gt;I believe it wasn't the fanciest solution but it works (I'm also in the process of learning &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;).&lt;BR /&gt;P.S. For the virtual table another code may be used with the same result in this particular case:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var vtab2 = ADDCOLUMNS(DISTINCT(SalesTable[Customer]), "code",[Margin check code])&lt;/LI-CODE&gt;&lt;P&gt;1. selectedcode variable gets code for each description from the MarginRange table. So for each row you just count the codes that are equal to the current one.&lt;/P&gt;&lt;P&gt;2. If you try to use virtual table with the VALUES funtion, you'll get an error: The VALUES function expects a column reference expression or a table reference expression for argument '1'.&lt;BR /&gt;You can either filter the whole table (not the best approach) or a column/number of columns. I'm not sure how to restrict a virtual table to a single column in this case.&lt;/P&gt;&lt;P&gt;3. There is a good article on measure totals (short answer - it depends on the context):&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/m-p/63376/highlight/true#M56" target="_blank"&gt;https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/m-p/63376/highlight/true#M56&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your first measure you could use HASONEFILTER or HASONEVALUE function to get the correct result in total.&lt;/P&gt;&lt;P&gt;DAX Studio can show you what it was calculating "behind the scenes":&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;SET DC_KIND="AUTO";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;SELECT&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;COUNT ( )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;FROM 'Table'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;WHERE&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;'Table'[code] IN ( null, 0 ) VAND&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;'Table'[code] IS NOT NULL;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Mar 2021 11:32:56 GMT</pubDate>
    <dc:creator>ERD</dc:creator>
    <dc:date>2021-03-31T11:32:56Z</dc:date>
    <item>
      <title>SUMMARIZECOLUMNS produces an error using as a virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMMARIZECOLUMNS-produces-an-error-using-as-a-virtual-table/m-p/1749523#M36428</link>
      <description>&lt;P&gt;Hi guys and girls,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following situation, simplified from my original challange.&amp;nbsp;I want to count a grouping measure to create a segmentation of customers depending on their performance (good, bad, ect.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here the data and data model&lt;/P&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;img /&gt;&lt;/P&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;&amp;nbsp;&lt;/P&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a range table manually&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;Range table&lt;/FONT&gt;&lt;/STRONG&gt;&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;&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;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;and a &lt;STRONG&gt;support table&lt;/STRONG&gt; with DAX&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;supporttable = SUMMARIZECOLUMNS(SalesTable[Customer], "code", [Margin check code])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Support table&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Margin Check&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;margin check total group = &lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;VAR selectedcode = SELECTEDVALUE(MarginRange[Code])&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;VAR returnsum =&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;CALCULATE(&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;COUNTX(supporttable,supporttable[code]),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;TREATAS(supporttable, SalesTable[Customer],MarginRange[Code]),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;FILTER(VALUES(supporttable[code]),supporttable[code] = selectedcode))&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;RETURN&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;returnsum&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This works ok and gives me the correct result&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But when I try so put that together in one measure using VAR, an Error comes up. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;The measure itself is correct at least from the syntax, but as soon I drag it in the table visual, I get this error.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;margin check total group VIRTUAL = &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;FONT color="#339966"&gt;VAR virtualtable = SUMMARIZECOLUMNS(SalesTable[Customer],"code",[Margin check code])&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;VAR selectedcode = SELECTEDVALUE(MarginRange[Code])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;VAR returnsum =&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;CALCULATE(&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;COUNTX(&lt;STRONG&gt;virtualtable&lt;/STRONG&gt;,[Customer]),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;TREATAS(&lt;STRONG&gt;virtualtable&lt;/STRONG&gt;, SalesTable[Customer],MarginRange[Code]),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;FILTER(&lt;STRONG&gt;virtualtable&lt;/STRONG&gt;,[code] = selectedcode))&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;returnsum&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;What does that mean? Whats wrong here?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks for helping me out. Hightly appreciated.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;pbix file here -&amp;gt;&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1W243RaSMFPzOSGR8H84DdX-CVOQbAeuB/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1W243RaSMFPzOSGR8H84DdX-CVOQbAeuB/view?usp=sharing&lt;/A&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226208" data-lia-user-login="mahoneypat" class="lia-mention lia-mention-user"&gt;mahoneypat&lt;/a&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&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;&amp;nbsp;&lt;/P&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;</description>
      <pubDate>Sat, 27 Mar 2021 16:53:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMMARIZECOLUMNS-produces-an-error-using-as-a-virtual-table/m-p/1749523#M36428</guid>
      <dc:creator>datadonuts</dc:creator>
      <dc:date>2021-03-27T16:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: SUMMARIZECOLUMNS produces an error using as a virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMMARIZECOLUMNS-produces-an-error-using-as-a-virtual-table/m-p/1749584#M36431</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="244606" data-lia-user-login="datadonuts" class="lia-mention lia-mention-user"&gt;datadonuts&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SUMMARIZECOLUMNS functions has some limitations described in this article:&amp;nbsp;&lt;A href="https://dax.guide/summarizecolumns/" target="_self"&gt;summarizecolumns (see Remarks sections)&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;An alternative is to use&amp;nbsp;SUMMARIZE + ADDCOLUMNS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is your measure:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;margin check total group VIRTUAL = 
var vtab2 = ADDCOLUMNS(SUMMARIZE(SalesTable, SalesTable[Customer]), "code",[Margin check code])
VAR selectedcode = SELECTEDVALUE(MarginRange[Code])
VAR returnsum =
CALCULATE(
    COUNTX(vtab2,[code]),
    FILTER(vtab2,[code] = selectedcode)
)
RETURN
returnsum&lt;/LI-CODE&gt;&lt;P&gt;And by the way, it shows correct value in totals in this case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#999999"&gt;Did I answer your question? Mark my post as a solution!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 19:38:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMMARIZECOLUMNS-produces-an-error-using-as-a-virtual-table/m-p/1749584#M36431</guid>
      <dc:creator>ERD</dc:creator>
      <dc:date>2021-03-27T19:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: SUMMARIZECOLUMNS produces an error using as a virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMMARIZECOLUMNS-produces-an-error-using-as-a-virtual-table/m-p/1749607#M36435</link>
      <description>&lt;P&gt;Thanks so much, great solution. I hope one day I can figure it out by myself in just minutes like you did, bc it took me a long, long, long time to get to my solution (I won't tell you how long &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May I kindly follow up the solution with some more question to better understand the mechanics behind that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Why it does not need the TREATAS function? As there is no relationship between the range table and the support/virtual table, I was thinking I need to build one. Why is that not necessary amd still works?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. You also removed the VALUES in the FILTER condition. I always believed, that you need VALUES in order to create a single column for the filter to iterate through, otherwise you get the error "Multiple columns ...."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally please tell me the secret which part of your solution generates the correct total. I tweaked my solution a bit to recreate it, but only your solution shows the correct total. Seems to be another hidden miracle in DAX I still don't understand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again, really appreciate your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 20:31:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMMARIZECOLUMNS-produces-an-error-using-as-a-virtual-table/m-p/1749607#M36435</guid>
      <dc:creator>datadonuts</dc:creator>
      <dc:date>2021-03-27T20:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: SUMMARIZECOLUMNS produces an error using as a virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMMARIZECOLUMNS-produces-an-error-using-as-a-virtual-table/m-p/1757326#M36713</link>
      <description>&lt;P&gt;Hi, sorry for the late response.&lt;/P&gt;&lt;P&gt;I believe it wasn't the fanciest solution but it works (I'm also in the process of learning &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;).&lt;BR /&gt;P.S. For the virtual table another code may be used with the same result in this particular case:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var vtab2 = ADDCOLUMNS(DISTINCT(SalesTable[Customer]), "code",[Margin check code])&lt;/LI-CODE&gt;&lt;P&gt;1. selectedcode variable gets code for each description from the MarginRange table. So for each row you just count the codes that are equal to the current one.&lt;/P&gt;&lt;P&gt;2. If you try to use virtual table with the VALUES funtion, you'll get an error: The VALUES function expects a column reference expression or a table reference expression for argument '1'.&lt;BR /&gt;You can either filter the whole table (not the best approach) or a column/number of columns. I'm not sure how to restrict a virtual table to a single column in this case.&lt;/P&gt;&lt;P&gt;3. There is a good article on measure totals (short answer - it depends on the context):&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/m-p/63376/highlight/true#M56" target="_blank"&gt;https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/m-p/63376/highlight/true#M56&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your first measure you could use HASONEFILTER or HASONEVALUE function to get the correct result in total.&lt;/P&gt;&lt;P&gt;DAX Studio can show you what it was calculating "behind the scenes":&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;SET DC_KIND="AUTO";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;SELECT&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;COUNT ( )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;FROM 'Table'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;WHERE&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;'Table'[code] IN ( null, 0 ) VAND&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;'Table'[code] IS NOT NULL;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 11:32:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUMMARIZECOLUMNS-produces-an-error-using-as-a-virtual-table/m-p/1757326#M36713</guid>
      <dc:creator>ERD</dc:creator>
      <dc:date>2021-03-31T11:32:56Z</dc:date>
    </item>
  </channel>
</rss>

