<?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: Add row/filter context to SUMMARIZECOLUMNS measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2567125#M73183</link>
    <description>&lt;P&gt;I don't think you'll get SUMMARIZECOLUMNS working in a measure, try using ADDCOLUMNS .. SUMMARIZE instead, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Unique Opened =
CALCULATE (
    COUNTROWS (
        ADDCOLUMNS (
            SUMMARIZE (
                fctActivities,
                fctActivities[CONTACT_ID],
                fctActivities[CAMPAIGNID],
                fctActivities[SUBJECTLINE]
            ),
            "CountEmailOpen",
                CALCULATE (
                    COUNTROWS ( fctActivities ),
                    fctActivities[ACTIVITYTYPE] = "EmailOpen"
                )
        )
    )
)&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 08 Jun 2022 16:19:43 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2022-06-08T16:19:43Z</dc:date>
    <item>
      <title>Add row/filter context to SUMMARIZECOLUMNS measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2566974#M73167</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following measure, which works on a total level, but not in a table visual with fields from another table (dimCampaigns):&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;Unique Opened = 
CALCULATE (
    COUNTROWS (
        SUMMARIZECOLUMNS(
            fctActivities[CONTACT_ID],
            fctActivities[CAMPAIGNID],
            fctActivities[SUBJECTLINE],
            "CountEmailOpen",
                CALCULATE (
                    COUNTROWS ( fctActivities ),
                    fctActivities[ACTIVITYTYPE] = "EmailOpen"
                )
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is probably because SUMMARIZECOLUMNS doesn't have a row context (as stated by &lt;A title="Introducing SUMMARIZECOLUMNS" href="https://www.sqlbi.com/articles/introducing-summarizecolumns/" target="_blank" rel="noopener"&gt;this article&lt;/A&gt;). So I figured I would have to somehow retrieve such a value from the filter context of the table visual containing data from 'dimCampaigns' into the measure manually (by using VALUES). So I created the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Unique Opened = 
CALCULATE (
    COUNTROWS (
        SUMMARIZECOLUMNS(
            fctActivities[CONTACT_ID],
            fctActivities[CAMPAIGNID],
            fctActivities[SUBJECTLINE],
            "CountEmailOpen",
                CALCULATE (
                    COUNTROWS ( fctActivities ),
                    fctActivities[ACTIVITYTYPE] = "EmailOpen",
                    VALUES(dimCampaigns[CAMPAIGNCATEGORY]),
                    VALUES(dimCampaigns[NAME])
                )
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This still works on the total level, but still not in the table visual. It's the following table visual where I would like to add the measure to, but if I use the above measure it gives the dreaded error "SummarizeColumns() and AddMissingItems() may not be used in this context.":&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;I think I'm close, but I just cannot get it to work. Any help would be much appreciated, thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 15:10:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2566974#M73167</guid>
      <dc:creator>RobinNeven</dc:creator>
      <dc:date>2022-06-08T15:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Add row/filter context to SUMMARIZECOLUMNS measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2567125#M73183</link>
      <description>&lt;P&gt;I don't think you'll get SUMMARIZECOLUMNS working in a measure, try using ADDCOLUMNS .. SUMMARIZE instead, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Unique Opened =
CALCULATE (
    COUNTROWS (
        ADDCOLUMNS (
            SUMMARIZE (
                fctActivities,
                fctActivities[CONTACT_ID],
                fctActivities[CAMPAIGNID],
                fctActivities[SUBJECTLINE]
            ),
            "CountEmailOpen",
                CALCULATE (
                    COUNTROWS ( fctActivities ),
                    fctActivities[ACTIVITYTYPE] = "EmailOpen"
                )
        )
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 Jun 2022 16:19:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2567125#M73183</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-06-08T16:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Add row/filter context to SUMMARIZECOLUMNS measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574740#M73663</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply! It's not an ideal solution, but what I did now is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a calculated table using the following DAX code (as I think it's better to use SUMMARIZECOLUMNS than SUMMARIZE/ADDCOLUMNS, as stated in the article I shared earlier), which is connected to the DimCampaigns table:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Subset = 
SUMMARIZECOLUMNS(
        fctActivities[CONTACT_ID],
        fctActivities[CAMPAIGNID],
        "CountEmailOpen",
            CALCULATE (
                COUNTROWS ( fctActivities ),
                fctActivities[ACTIVITYTYPE] = "EmailOpen"
            )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a measue in which I simply COUNTROWS in the above calculated table named 'Subset':&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Unique Opened = COUNTROWS('Subset')&lt;/LI-CODE&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;Somehow it doesn't work to simply replace 'Subset' in the measure with the DAX code that's creating the calculated table, also not using variables, this probably has something to do with context transition not working.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 09:44:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574740#M73663</guid>
      <dc:creator>RobinNeven</dc:creator>
      <dc:date>2022-06-13T09:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Add row/filter context to SUMMARIZECOLUMNS measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574764#M73664</link>
      <description>&lt;P&gt;Replacing the table name with the DAX, or a variable calculated from the DAX, won't work if you use SUMMARIZECOLUMNS, you can't use that in a measure. If you edit it to use ADDCOLUMNS ... SUMMARIZE then it might work&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 09:45:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574764#M73664</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-06-13T09:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Add row/filter context to SUMMARIZECOLUMNS measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574786#M73667</link>
      <description>&lt;P&gt;So you mean creating one single measure as the following? Because that doesn't work either...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Unique Opened = 
CALCULATE (
    COUNTROWS (
        ADDCOLUMNS (
            SUMMARIZE (
                fctActivities,
                fctActivities[CONTACT_ID],
                fctActivities[CAMPAIGNID]
            ),
            "CountEmailOpen",
                CALCULATE (
                    COUNTROWS ( fctActivities ),
                    fctActivities[ACTIVITYTYPE] = "EmailOpen"
                )
        )
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Jun 2022 09:52:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574786#M73667</guid>
      <dc:creator>RobinNeven</dc:creator>
      <dc:date>2022-06-13T09:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Add row/filter context to SUMMARIZECOLUMNS measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574821#M73669</link>
      <description>&lt;P&gt;Try creating a temporary table to see if you can spot what the problem might be,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Tmp Table =
        ADDCOLUMNS (
            SUMMARIZE (
                fctActivities,
                fctActivities[CONTACT_ID],
                fctActivities[CAMPAIGNID]
            ),
            "CountEmailOpen",
                CALCULATE (
                    COUNTROWS ( fctActivities ),
                    fctActivities[ACTIVITYTYPE] = "EmailOpen"
                )
        )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Jun 2022 09:59:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574821#M73669</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-06-13T09:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Add row/filter context to SUMMARIZECOLUMNS measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574981#M73682</link>
      <description>&lt;P&gt;There is no problem with that code as such.&amp;nbsp;The problem lies in the combination of that piece of code in a measure like below, the problem being that the measure is not properly filtered by (fields from) dimCampaigns in said table visual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Unique Opened = 
CALCULATE (
    COUNTROWS (
        ADDCOLUMNS (
            SUMMARIZE (
                fctActivities,
                fctActivities[CONTACT_ID],
                fctActivities[CAMPAIGNID]
            ),
            "CountEmailOpen",
                CALCULATE (
                    COUNTROWS ( fctActivities ),
                    fctActivities[ACTIVITYTYPE] = "EmailOpen"
                )
        )
    ),FILTER('Subset', 'Subset'[CountEmailOpen] &amp;gt; 0)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Jun 2022 10:53:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-row-filter-context-to-SUMMARIZECOLUMNS-measure/m-p/2574981#M73682</guid>
      <dc:creator>RobinNeven</dc:creator>
      <dc:date>2022-06-13T10:53:05Z</dc:date>
    </item>
  </channel>
</rss>

