<?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 slicer to a filtered measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4111763#M163178</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- If you change your original measure to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Ttl_Device_Cnt_Vendor1 = 

CALCULATE (
SUM('Counts'[DeviceCnt]),
KEEPFILTERS('Counts'[vendor_name]) = "Vendor1" ))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it will keep the filter context of "Vendor1" but still allow all other filter contexts, such as selections in the region slicer to affect its value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this works for you, please accept as the solution.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 16:54:13 GMT</pubDate>
    <dc:creator>mark_endicott</dc:creator>
    <dc:date>2024-08-21T16:54:13Z</dc:date>
    <item>
      <title>Add slicer to a filtered measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4111707#M163176</link>
      <description>&lt;P&gt;I have a situation where I have 5 vendors that each have the same four regions (North, East, West, South). I have a simple table that has the vendor_name, region_name, and devicecnt fields that is updated nightly for current data only.&amp;nbsp; On my dashboard, I had created&amp;nbsp;individual KPI style cards for each vendor that shows their current counts, each with their own measure with the vendor name changed:&lt;/P&gt;&lt;P&gt;Ttl_Device_Cnt_Vendor1 = calculate (&lt;BR /&gt;SUM('Counts'[DeviceCnt]),&lt;BR /&gt;FILTER (&lt;BR /&gt;ALL ( 'Counts' ),&lt;BR /&gt;('Counts'[vendor_name]) IN { "Vendor1" }&lt;BR /&gt;))&lt;/P&gt;&lt;P&gt;this works great for each individual vendor, but now I want to add another multi-select slicer for regions so users can interact with other visuals on the page. I would like to have the region slicer affect these vendor measures, so I used Dax Studio to build a dax query:&lt;/P&gt;&lt;P&gt;Ttl_Device_Cnt_Vendor1 =&lt;BR /&gt;SUMMARIZECOLUMNS(&lt;BR /&gt;'Counts'[DeviceCnt],&lt;BR /&gt;KEEPFILTERS( TREATAS( {"North","East","West",South"}, 'Counts'[region_name] )),&lt;BR /&gt;KEEPFILTERS( TREATAS( {"Vendor1"}, 'Counts'[vendor_name] ))&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;This works when there is only one region selected on the slicer, but returns an error when more than one slicer value is chosen:&lt;/P&gt;&lt;P&gt;MdxScript(Model) (42,1) Calculation error in measure [Ttl_Device_Cnt_Vendor1]; A table of multiple vales was supplied where a single value was expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me updated my Dax measure to keep the vendor name filter, but be able to handle more than one region slice value.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 16:29:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4111707#M163176</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-21T16:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Add slicer to a filtered measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4111763#M163178</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- If you change your original measure to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Ttl_Device_Cnt_Vendor1 = 

CALCULATE (
SUM('Counts'[DeviceCnt]),
KEEPFILTERS('Counts'[vendor_name]) = "Vendor1" ))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it will keep the filter context of "Vendor1" but still allow all other filter contexts, such as selections in the region slicer to affect its value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this works for you, please accept as the solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 16:54:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4111763#M163178</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2024-08-21T16:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Add slicer to a filtered measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4111818#M163180</link>
      <description>&lt;P&gt;Thank you for responding! unfortunately I am receiving a new error now:&lt;/P&gt;&lt;P&gt;KEEPFILTERS function can only be used as a top level filter argument of CALCULATE and CALCULATETABLE or with a table argument of a function performing a table scan.&lt;/P&gt;&lt;P&gt;Here is the updated DAX:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Ttl_Device_Cnt_Test =&lt;/SPAN&gt; &lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Counts'&lt;/SPAN&gt;&lt;SPAN&gt;[DeviceCnt]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;KEEPFILTERS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Counts'&lt;/SPAN&gt;&lt;SPAN&gt;[vendor_Name]&lt;/SPAN&gt;&lt;SPAN&gt;) = &lt;/SPAN&gt;&lt;SPAN&gt;"Vendor1"&lt;/SPAN&gt;&lt;SPAN&gt; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Aug 2024 17:29:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4111818#M163180</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-21T17:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Add slicer to a filtered measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4113015#M163229</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- Where are you attempting to use this DAX? It should work fine in a measure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is some more guidance on the use of KEEPFILTERS:&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/using-keepfilters-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/using-keepfilters-in-dax/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this doesn't help, I'll need some more information, perhpas a screenshot and some information about your model.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this works for you, please accept as the solution.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 08:17:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4113015#M163229</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2024-08-22T08:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Add slicer to a filtered measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4114948#M163326</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you can modify your formula like below:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Ttl_Device_Cnt_Vendor1 = 
VAR SelectedRegions = SELECTEDVALUE('Counts'[region_name])
VAR SelectedVendor = "Vendor1"
RETURN
CALCULATE(
    SUM('Counts'[devicecnt]),
    FILTER(
        ALL('Counts'[region_name]),
        'Counts'[region_name] = SelectedRegions
    ),
    'Counts'[vendor_name] = SelectedVendor
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Adamk Kong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 06:12:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4114948#M163326</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-23T06:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Add slicer to a filtered measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4115425#M163349</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- This is wrong.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) SELECTEDVALUE will not accept the input of multiple Regions (should this be necessary) leading to a Blank result. And, if no region is selected there will be a Blank result also.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) KEEPFILTERS is more optimal, and will respect the filter context applied by any other field in the model.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3) It will not solve&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;'s issue, which appears to be that they are using my solution in the wrong place.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 09:26:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4115425#M163349</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2024-08-23T09:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Add slicer to a filtered measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4115868#M163386</link>
      <description>&lt;P&gt;Mark, I was finally able to get your solution to work after fixing a tiny syntax error in it:&lt;/P&gt;&lt;PRE&gt;Ttl_Device_Cnt_Vendor1 = 

CALCULATE (
SUM('Counts'[DeviceCnt]),
KEEPFILTERS('Counts'[vendor_name]) = "Vendor1" ))&lt;/PRE&gt;&lt;P&gt;has an extra right-parenthesis after 'counts'[vendor_name] that once removed, allows the region slicers to work as expected.&lt;/P&gt;&lt;P&gt;this works for me:&lt;/P&gt;&lt;P&gt;Ttl_Device_Cnt_Test =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM('counts'[DeviceCnt]),&lt;BR /&gt;KEEPFILTERS('counts'[vendor_name] = "vendor1" ))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your patience and assistance! truly appreciated!!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 14:02:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4115868#M163386</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-23T14:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Add slicer to a filtered measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4120321#M163586</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- Ah yes, I see where I'd accidentally put the additional ")". Sorry for that, glad you reached the solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 08:46:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Add-slicer-to-a-filtered-measure/m-p/4120321#M163586</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2024-08-27T08:46:40Z</dc:date>
    </item>
  </channel>
</rss>

