<?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 contains function is very slow in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1009785#M12892</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a measure that checks for the existence of certain rows with specific conditions and returns certain values if the condition is met as per the pseudo code below:&lt;/P&gt;&lt;P&gt;if a row with condition1 exists:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; { return value1}&lt;BR /&gt;else if a row with condition2 exists&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; { return value2}&lt;BR /&gt;else if a row with condition3 exists&lt;BR /&gt;&amp;nbsp; &amp;nbsp; { return value3}&lt;BR /&gt;else&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;{return blank}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote the dax measure as follows:&lt;/P&gt;&lt;P&gt;IF(CONTAINS('TableX','TableX'[ColumnA],"Condition1"),"Value1",IF(CONTAINS('TableX','TableX'[ColumnA],"Condition2"),"Value2",IF(CONTAINS('TableX','TableX'[ColumnA],"Condition3"),"Value3",BLANK())))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measure is extremely slow. Can someone please help me optimizing it?&lt;/P&gt;</description>
    <pubDate>Mon, 06 Apr 2020 11:41:19 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-04-06T11:41:19Z</dc:date>
    <item>
      <title>contains function is very slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1009785#M12892</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a measure that checks for the existence of certain rows with specific conditions and returns certain values if the condition is met as per the pseudo code below:&lt;/P&gt;&lt;P&gt;if a row with condition1 exists:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; { return value1}&lt;BR /&gt;else if a row with condition2 exists&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; { return value2}&lt;BR /&gt;else if a row with condition3 exists&lt;BR /&gt;&amp;nbsp; &amp;nbsp; { return value3}&lt;BR /&gt;else&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;{return blank}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote the dax measure as follows:&lt;/P&gt;&lt;P&gt;IF(CONTAINS('TableX','TableX'[ColumnA],"Condition1"),"Value1",IF(CONTAINS('TableX','TableX'[ColumnA],"Condition2"),"Value2",IF(CONTAINS('TableX','TableX'[ColumnA],"Condition3"),"Value3",BLANK())))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measure is extremely slow. Can someone please help me optimizing it?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 11:41:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1009785#M12892</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-06T11:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: contains function is very slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1009841#M12894</link>
      <description>&lt;P&gt;Perhaps replace your CONTAINS with IN?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see this post regarding How to Get Your Question Answered Quickly: &lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 12:08:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1009841#M12894</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-04-06T12:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: contains function is very slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1009978#M12898</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;Can you please post some screenshots on the data you are using in your pseudo code?&lt;/P&gt;&lt;P&gt;It is hard to judge what is the issue with your DAX expression with CONTAINS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pragati&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 13:14:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1009978#M12898</guid>
      <dc:creator>Pragati11</dc:creator>
      <dc:date>2020-04-06T13:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: contains function is very slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1009993#M12899</link>
      <description>&lt;P&gt;Thanks Greg. However, containsrow and in do not serve my purpose. They are both used as filters for the filter function as per this explanation&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/dax/in-operator-containsrow-function" target="_blank"&gt;https://docs.microsoft.com/en-us/dax/in-operator-containsrow-function&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my scenario, I want to check the existance of a row in a table. I need the equivalent of IF EXISTS(SELECT * FROM Table1 WHERE Column1 = Value1) in SQL. This is why I used the CONTAINS but unfortunately, it is extremely slow that the visual is not even loading.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 13:20:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1009993#M12899</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-06T13:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: contains function is very slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1010137#M12902</link>
      <description>&lt;P&gt;Hi Pragati,&lt;/P&gt;&lt;P&gt;Here is sample data for the raw data. The data consists of:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Dates&lt;/LI&gt;&lt;LI&gt;Employees&lt;/LI&gt;&lt;LI&gt;Activities to be performed by employees denoted by A1, A2, A3, etc...&lt;/LI&gt;&lt;LI&gt;Activity Status which indicates whether an activity was complete or not. The values are as follows:&lt;UL&gt;&lt;LI&gt;If the activity was completed, then the data shows "Yes"&lt;/LI&gt;&lt;LI&gt;If the activity was not completed, then the data is "No"&lt;/LI&gt;&lt;LI&gt;If no information was provided, we have "Unknown"&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;HoursSpent: when an activity is completed, this column indicates the number of hours it took the employee to complete this activity&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&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TD&gt;A3&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03/04/2020&lt;/TD&gt;&lt;TD&gt;E3&lt;/TD&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;Unknown&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above data needs to visualized as in a matrix visual as shown below:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;REQUIRED RESULT&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;01/04/2020&lt;/TD&gt;&lt;TD&gt;02/04/2020&lt;/TD&gt;&lt;TD&gt;03/04/2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;E1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;E2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;E3&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Employees are the rows while the dates are the columnn. The values are the result of the measure I am trying to create described below:&lt;/P&gt;&lt;P&gt;IF (Employee completed ANY activity on particular day &lt;EM&gt;&lt;FONT color="#FF0000"&gt;-- here we do not care about the activity. all we care for is whether the employee completed any of the activities or not on that particular day&lt;/FONT&gt;&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Result = SUM(HoursSpent)&lt;/P&gt;&lt;P&gt;ELSE IF (Employee did not complete any activity on particular day&lt;EM&gt;&lt;FONT color="#FF0000"&gt; -- here too all we care about is whether the employee did not complete any activity on that particular day&lt;/FONT&gt;&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Result = "No"&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Result = ""&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 14:11:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1010137#M12902</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-06T14:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: contains function is very slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1010294#M12905</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;A question here. How can you create a calucation &lt;STRONG&gt;"Result"&lt;/STRONG&gt; having&lt;U&gt;&lt;EM&gt; 2 different data-types&lt;/EM&gt;&lt;/U&gt; in it?&lt;/P&gt;&lt;P&gt;In your case &lt;U&gt;SUM(Hours_Spent) is Numeric&lt;/U&gt; and &lt;U&gt;Activity Status is String&lt;/U&gt;.&lt;/P&gt;&lt;P&gt;Your &lt;STRONG&gt;Result&lt;/STRONG&gt; column can't have values with 2 different data-types.&lt;/P&gt;&lt;P&gt;Do you still want to do something like this or try a different way of representing your data?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pragati&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 15:12:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1010294#M12905</guid>
      <dc:creator>Pragati11</dc:creator>
      <dc:date>2020-04-06T15:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: contains function is very slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1010438#M12911</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81077" data-lia-user-login="Pragati11" class="lia-mention lia-mention-user"&gt;Pragati11&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You can have 2 different data-types with measures but you can not do it with calculated columns. I have already done the logic and the measure works perfectly fine as indicated in my first post. The issue is that it is very slow. When I use it in a table it works perfectly fine but when I use it in a matrix visual, it takes forever to load (24minutes to be exact).&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 15:52:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1010438#M12911</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-06T15:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: contains function is very slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1010479#M12913</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually took your calculation as a caluclated column that's asked that 2 different data-type thing. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Yes for measure it works.&lt;/P&gt;&lt;P&gt;I will see if I can get a way to fix this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Pragati&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 16:03:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/contains-function-is-very-slow/m-p/1010479#M12913</guid>
      <dc:creator>Pragati11</dc:creator>
      <dc:date>2020-04-06T16:03:39Z</dc:date>
    </item>
  </channel>
</rss>

