<?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 A lot of IF and OR statements - Making it run slow in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3750794#M146287</link>
    <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I am having some issues with the performance of some of my reports, due to some measures running slow.&lt;BR /&gt;&lt;BR /&gt;Some base info:&lt;BR /&gt;I am connected to an Azure Blob Storage, collecting data in CSV format.&lt;BR /&gt;I do some cleaning using Power Query&lt;BR /&gt;&lt;BR /&gt;The measure(s) in question:&lt;BR /&gt;Newsletter Permissions&lt;BR /&gt;&lt;BR /&gt;For my company there are some different criteria a recipient have to have, in order to be have a newsletter permission, and they are:&amp;nbsp;&lt;BR /&gt;If any of the following are true:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;IF(&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[ComplaintCheck]=1 ||&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[LastEmailCheck]=1 || (It's more than 365 days since you last got an email)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[MalformedCheck]=1 ||&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[ValidEmailCheck]=1 ||&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[UnsubscribedCheck]=1&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;OR if ALL of the following are true or BLANK:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;IF(&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Created more than 365 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;First use of app is more than 365 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Your last app use is more than 1000 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Your last interaction is more than 1000 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Your last web use is more than 1000 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Your permission is set within the last 365 days&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;For all of the above I have made a seperate measure looking like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;IF(&lt;BR /&gt;&amp;nbsp; &amp;nbsp;OR(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NOT(SUM('agillic-targetgroup'[Days Since First Use])&amp;lt;365),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; SUM('agillic-targetgroup'[Days Since First Use])=BLANK()&lt;BR /&gt;&amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;,1&lt;BR /&gt;&amp;nbsp; &amp;nbsp;,0&lt;BR /&gt;)&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&lt;BR /&gt;I have used Power Query to created columns that calculate how many days it has been since the different dates.&lt;BR /&gt;&lt;BR /&gt;I can provide a sample set if needed.&lt;BR /&gt;&lt;BR /&gt;I hope some of you can help.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 08 Mar 2024 07:47:04 GMT</pubDate>
    <dc:creator>EmilZPM</dc:creator>
    <dc:date>2024-03-08T07:47:04Z</dc:date>
    <item>
      <title>A lot of IF and OR statements - Making it run slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3750794#M146287</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I am having some issues with the performance of some of my reports, due to some measures running slow.&lt;BR /&gt;&lt;BR /&gt;Some base info:&lt;BR /&gt;I am connected to an Azure Blob Storage, collecting data in CSV format.&lt;BR /&gt;I do some cleaning using Power Query&lt;BR /&gt;&lt;BR /&gt;The measure(s) in question:&lt;BR /&gt;Newsletter Permissions&lt;BR /&gt;&lt;BR /&gt;For my company there are some different criteria a recipient have to have, in order to be have a newsletter permission, and they are:&amp;nbsp;&lt;BR /&gt;If any of the following are true:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;IF(&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[ComplaintCheck]=1 ||&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[LastEmailCheck]=1 || (It's more than 365 days since you last got an email)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[MalformedCheck]=1 ||&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[ValidEmailCheck]=1 ||&lt;BR /&gt;&amp;nbsp; &amp;nbsp;[UnsubscribedCheck]=1&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;OR if ALL of the following are true or BLANK:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;IF(&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Created more than 365 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;First use of app is more than 365 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Your last app use is more than 1000 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Your last interaction is more than 1000 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Your last web use is more than 1000 days ago&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Your permission is set within the last 365 days&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;For all of the above I have made a seperate measure looking like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;IF(&lt;BR /&gt;&amp;nbsp; &amp;nbsp;OR(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NOT(SUM('agillic-targetgroup'[Days Since First Use])&amp;lt;365),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; SUM('agillic-targetgroup'[Days Since First Use])=BLANK()&lt;BR /&gt;&amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;,1&lt;BR /&gt;&amp;nbsp; &amp;nbsp;,0&lt;BR /&gt;)&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&lt;BR /&gt;I have used Power Query to created columns that calculate how many days it has been since the different dates.&lt;BR /&gt;&lt;BR /&gt;I can provide a sample set if needed.&lt;BR /&gt;&lt;BR /&gt;I hope some of you can help.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 08 Mar 2024 07:47:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3750794#M146287</guid>
      <dc:creator>EmilZPM</dc:creator>
      <dc:date>2024-03-08T07:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: A lot of IF and OR statements - Making it run slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3750976#M146293</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="696251" data-lia-user-login="EmilZPM" class="lia-mention lia-mention-user"&gt;EmilZPM&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;You can try following below steps,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;1. Create measures for each condition:&lt;/P&gt;
&lt;P&gt;2. Create measures for ComplaintCheck, LastEmailCheck, MalformedCheck, ValidEmailCheck, and UnsubscribedCheck. These measures should return 1 if the condition is true and 0 otherwise.&lt;/P&gt;
&lt;P&gt;3. Create measures for DaysSinceLastEmail, DaysSinceCreated, DaysSinceFirstAppUse, DaysSinceLastAppUse, DaysSinceLastInteraction, and DaysSinceLastWebUse. These measures should calculate the number of days since the corresponding events occurred.&lt;/P&gt;
&lt;P&gt;4. Create a measure for PermissionSetWithin365Days to check if permission is set within the last 365 days.&lt;/P&gt;
&lt;P&gt;DAX for these will be as follows:&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;ComplaintCheck = IF([ComplaintCheck]=1, 1, 0) &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;LastEmailCheck = IF([LastEmailCheck]=1 || [DaysSinceLastEmail] &amp;gt; 365, 1, 0) &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;MalformedCheck = IF([MalformedCheck]=1, 1, 0) &lt;BR /&gt;ValidEmailCheck = IF([ValidEmailCheck]=1, 1, 0) &lt;BR /&gt;UnsubscribedCheck = IF([UnsubscribedCheck]=1, 1, 0) &lt;BR /&gt;DaysSinceCreated = DATEDIFF([CreatedDate], TODAY(), DAY) &lt;BR /&gt;DaysSinceFirstAppUse = DATEDIFF([FirstAppUseDate], TODAY(), DAY) &lt;BR /&gt;DaysSinceLastAppUse = DATEDIFF([LastAppUseDate], TODAY(), DAY) &lt;BR /&gt;DaysSinceLastInteraction = DATEDIFF([LastInteractionDate], TODAY(), DAY) &lt;BR /&gt;DaysSinceLastWebUse = DATEDIFF([LastWebUseDate], TODAY(), DAY) &lt;BR /&gt;PermissionSetWithin365Days = IF([PermissionDate] &amp;gt;= TODAY() - 365, 1, 0)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Create measure with below DAX for logical operations,&lt;BR /&gt;&lt;BR /&gt;NewsletterPermissions = IF( [ComplaintCheck] + [LastEmailCheck] + [MalformedCheck] + [ValidEmailCheck] + [UnsubscribedCheck] &amp;gt; 0, 1, IF( [DaysSinceCreated] &amp;gt; 365 &amp;amp;&amp;amp; [DaysSinceFirstAppUse] &amp;gt; 365 &amp;amp;&amp;amp; [DaysSinceLastAppUse] &amp;gt; 1000 &amp;amp;&amp;amp; [DaysSinceLastInteraction] &amp;gt; 1000 &amp;amp;&amp;amp; [DaysSinceLastWebUse] &amp;gt; 1000 &amp;amp;&amp;amp; [PermissionSetWithin365Days] = 1, 1, 0 ) )&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;Inogic Professional Service Division&lt;/P&gt;
&lt;P&gt;An expert technical extension for your techno-functional business needs&lt;/P&gt;
&lt;P&gt;Power Platform/Dynamics 365 CRM&lt;/P&gt;
&lt;P&gt;Drop an email at&amp;nbsp;&lt;A href="mailto:crm@inogic.com" target="_blank" rel="nofollow noopener noreferrer"&gt;crm@inogic.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Service:&amp;nbsp;&amp;nbsp;&lt;A href="http://www.inogic.com/services/" target="_blank" rel="nofollow noopener noreferrer"&gt;http://www.inogic.com/services/&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Power Platform/Dynamics 365 CRM Tips and Tricks:&amp;nbsp;&amp;nbsp;&lt;A href="http://www.inogic.com/blog/" target="_blank" rel="nofollow noopener noreferrer"&gt;http://www.inogic.com/blog/&lt;/A&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2024 09:00:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3750976#M146293</guid>
      <dc:creator>SamInogic</dc:creator>
      <dc:date>2024-03-08T09:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: A lot of IF and OR statements - Making it run slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3751170#M146308</link>
      <description>&lt;P&gt;Doing the check with "+" istead of or, helped.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"IF( [DaysSinceCreated] &amp;gt; 365 &amp;amp;&amp;amp; [DaysSinceFirstAppUse] &amp;gt; 365 &amp;amp;&amp;amp; [DaysSinceLastAppUse] &amp;gt; 1000 &amp;amp;&amp;amp; [DaysSinceLastInteraction] &amp;gt; 1000 &amp;amp;&amp;amp; [DaysSinceLastWebUse] &amp;gt; 1000 &amp;amp;&amp;amp; [PermissionSetWithin365Days] = 1"&lt;BR /&gt;&lt;/SPAN&gt;This does not work, because for all of them they can either be BLANK or older tham 365 or 1000 days.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2024 10:10:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3751170#M146308</guid>
      <dc:creator>EmilZPM</dc:creator>
      <dc:date>2024-03-08T10:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: A lot of IF and OR statements - Making it run slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3754325#M146472</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="696251" data-lia-user-login="EmilZPM" class="lia-mention lia-mention-user"&gt;EmilZPM&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Based on your description, you can try the following measure to see if it works&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
IF (
    [ComplaintCheck] + [LastEmailCheck] + [MalformedCheck] + [ValidEmailCheck] + [UnsubscribedCheck] &amp;gt; 0,
    1,
    IF (
        ( [DaysSinceCreated] &amp;gt; 365
            &amp;amp;&amp;amp; [DaysSinceFirstAppUse] &amp;gt; 365
            &amp;amp;&amp;amp; [DaysSinceLastAppUse] &amp;gt; 1000
            &amp;amp;&amp;amp; [DaysSinceLastInteraction] &amp;gt; 1000
            &amp;amp;&amp;amp; [DaysSinceLastWebUse] &amp;gt; 1000
            &amp;amp;&amp;amp; [PermissionSetWithin365Days] = 1 )
            || (
                ISBLANK ( [DaysSinceCreated] ) &amp;amp;&amp;amp; ISBLANK ( [DaysSinceFirstAppUse] )
                    &amp;amp;&amp;amp; ISBLANK ( [DaysSinceLastAppUse] )
                    &amp;amp;&amp;amp; ISBLANK ( [DaysSinceLastInteraction] )
                    &amp;amp;&amp;amp; ISBLANK ( [DaysSinceLastWebUse] )
                    &amp;amp;&amp;amp; ISBLANK ( [PermissionSetWithin365Days] )
            ),
        1,
        0
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this does not work, could you please share some sample data without sensitive information and expected output.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;to&lt;/STRONG&gt; help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to get your questions answered quickly&lt;/A&gt;&amp;nbsp;--&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;&amp;nbsp;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2024 07:47:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3754325#M146472</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-11T07:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: A lot of IF and OR statements - Making it run slow</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3777592#M147651</link>
      <description>&lt;P&gt;Unfortunately it is still very heavy, and sometimes times out on the refresh.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have shared a sample dataset and a power bi file containing the measures I have made.&lt;BR /&gt;The sample is only approx 4k lines, where the full data is 1m lines.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://drive.google.com/file/d/16tDp3ph5UbVx_gv4qkzORECxYMQ60kkt/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/16tDp3ph5UbVx_gv4qkzORECxYMQ60kkt/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/17vWtcnHGDqiHoB4Vvh8kGMh8x-1cpDxy/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/17vWtcnHGDqiHoB4Vvh8kGMh8x-1cpDxy/view?usp=sharing&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Let me know if this isn't enough.&lt;BR /&gt;&lt;BR /&gt;And thanks for the help!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 08:01:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-lot-of-IF-and-OR-statements-Making-it-run-slow/m-p/3777592#M147651</guid>
      <dc:creator>EmilZPM</dc:creator>
      <dc:date>2024-03-20T08:01:29Z</dc:date>
    </item>
  </channel>
</rss>

