<?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: Calculate function using Containsstring filter not working as expected in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2432329#M64800</link>
    <description>&lt;P&gt;Hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you could try this Measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ACT% =
DIVIDE (
    CALCULATE (
        SUM ( vw_shrinkage_act[Total_Hrs] ),
        FILTER ( vw_shrinkage_act, vw_shrinkage_act[Shrinkage_cat_code] &amp;lt;&amp;gt; "SHIFT" )
    ),
    CALCULATE (
        SUM ( vw_shrinkage_act[Total_Hrs] ),
        CONTAINSSTRING ( vw_shrinkage_act[Shrinkage_cat_code], "SHIFT" )
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the result will look like this:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider&lt;STRONG&gt; Accept it as the solution&lt;/STRONG&gt; to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _ Caiyun&lt;/P&gt;</description>
    <pubDate>Fri, 01 Apr 2022 14:17:03 GMT</pubDate>
    <dc:creator>v-cazheng-msft</dc:creator>
    <dc:date>2022-04-01T14:17:03Z</dc:date>
    <item>
      <title>Calculate function using Containsstring filter not working as expected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2422504#M64235</link>
      <description>&lt;P&gt;Hey Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sure I'm missing something small in the syntax here but I've tried this DAX measure about every way possible the past couple days without any luck.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table called 'vw_shrinkage_act' and I'm using two columns to derive a calculated measure, [Total_Hrs] and [Shrinkage_cat_code] . I break these down by day of week in the matrix tables below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm just trying to divide the Total Hrs column by itself with help of filters. The denominator needs to be category "Shift" and the numerator needs to be all the other category codes EXCEPT for "Shift" as it just adds itself (100%) to the overall sum which isn't helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What seems to work, but without filtering out "Shift" from numerator: Visual breaks if I deselect "Shift" in a slicer&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ACT% = DIVIDE (
    CALCULATE(
        SUM(vw_shrinkage_act[Total_Hrs])),
    CALCULATE(
        SUM(vw_shrinkage_act[Total_Hrs]), 
        CONTAINSSTRING(vw_shrinkage_act[Shrinkage_cat_code], "SHIFT")
    ))&lt;/LI-CODE&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I expected to work, but it does some weird aggregation that's completely not helpful...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ACT% = DIVIDE (
    CALCULATE(
        SUM(vw_shrinkage_act[Total_Hrs]), 
    NOT CONTAINSSTRING(vw_shrinkage_act[Shrinkage_cat_code], "SHIFT")),
    CALCULATE(
        SUM(vw_shrinkage_act[Total_Hrs]), 
        CONTAINSSTRING(vw_shrinkage_act[Shrinkage_cat_code], "SHIFT")
    ))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 20:42:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2422504#M64235</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-28T20:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function using Containsstring filter not working as expected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2422555#M64242</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;Instead of using ContainsString can you consider trying a measure like:&lt;/P&gt;&lt;P&gt;Share =&amp;nbsp;&lt;/P&gt;&lt;P&gt;= DIVIDE(SUMX(&lt;/P&gt;&lt;PRE&gt;vw_shrinkage_act[Total_Hrs]&lt;/PRE&gt;&lt;P&gt;),&lt;/P&gt;&lt;P&gt;SUMX(ALLSELECTED(&lt;/P&gt;&lt;P&gt;vw_shrinkage_act), [Total Hours]))&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 21:12:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2422555#M64242</guid>
      <dc:creator>Whitewater100</dc:creator>
      <dc:date>2022-03-28T21:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function using Containsstring filter not working as expected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2424890#M64375</link>
      <description>&lt;P&gt;That doesn't quite work for what I'm trying to do. Example table below&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Category&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Absence&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Leave&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Break&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Shift&lt;/TD&gt;&lt;TD&gt;82&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Absence / Shift = 0.146 or 14.6%&lt;BR /&gt;Leave / Shift = 0.048 or 4.8%&lt;BR /&gt;Break / Shift = 0.036 or 3.6%&lt;BR /&gt;All / Shift = 0.231 or 23.1%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I run into is that Shift / Shift = 100% and it gets added to the total values which just makes everything wrong. "Shift" is only there to be the denominator in the division, I need it excluded from the numerator which is where I got to the two measures I originally posted.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 16:40:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2424890#M64375</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-29T16:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function using Containsstring filter not working as expected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2425023#M64385</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;I understand. Can you try this link for report? There is a table with calculation as well, but most are measures. I hope this helps!&lt;/P&gt;&lt;P&gt;&lt;A title="Perc of Shift" href="https://drive.google.com/file/d/1O81vtC1QOyE_hoiLrBttXw-6Ibr9X1uE/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/1O81vtC1QOyE_hoiLrBttXw-6Ibr9X1uE/view?usp=sharing&lt;/A&gt;&amp;nbsp;&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;</description>
      <pubDate>Tue, 29 Mar 2022 17:43:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2425023#M64385</guid>
      <dc:creator>Whitewater100</dc:creator>
      <dc:date>2022-03-29T17:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function using Containsstring filter not working as expected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2425112#M64393</link>
      <description>&lt;P&gt;Hey thanks for writing up these examples. We are super close here. The only issue left is that "Tot Shift" being MAX(value) isn't usable. My source table has many thousands of rows, there are many values for "Shift" being Summed and aggregated, so dividing by the maximum value of Shift yields incorrect math. I tried making some changes but I guess I can't use SELECTEDVALUE on a calculated measure.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 19:10:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2425112#M64393</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-29T19:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function using Containsstring filter not working as expected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2425217#M64401</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;No problem. They are based on what you shared. You can have a variable in a calculated measure.&lt;/P&gt;&lt;P&gt;Measure Name&lt;/P&gt;&lt;P&gt;var shift = Table[Shift[ID]&lt;/P&gt;&lt;P&gt;return&lt;/P&gt;&lt;P&gt;the DAX referring to this variable.&amp;nbsp; Example only.&lt;/P&gt;&lt;P&gt;return&lt;/P&gt;&lt;P&gt;Do you have example data(Model-table-visual you want to create) that reflects all the nuances&amp;nbsp; to writing the DAX?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 20:36:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2425217#M64401</guid>
      <dc:creator>Whitewater100</dc:creator>
      <dc:date>2022-03-29T20:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate function using Containsstring filter not working as expected</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2432329#M64800</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you could try this Measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ACT% =
DIVIDE (
    CALCULATE (
        SUM ( vw_shrinkage_act[Total_Hrs] ),
        FILTER ( vw_shrinkage_act, vw_shrinkage_act[Shrinkage_cat_code] &amp;lt;&amp;gt; "SHIFT" )
    ),
    CALCULATE (
        SUM ( vw_shrinkage_act[Total_Hrs] ),
        CONTAINSSTRING ( vw_shrinkage_act[Shrinkage_cat_code], "SHIFT" )
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the result will look like this:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider&lt;STRONG&gt; Accept it as the solution&lt;/STRONG&gt; to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _ Caiyun&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 14:17:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-function-using-Containsstring-filter-not-working-as/m-p/2432329#M64800</guid>
      <dc:creator>v-cazheng-msft</dc:creator>
      <dc:date>2022-04-01T14:17:03Z</dc:date>
    </item>
  </channel>
</rss>

