<?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 new column based on multiple conditions from two different tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557707#M72679</link>
    <description>&lt;P&gt;Table2 is the date table itself&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jun 2022 10:52:20 GMT</pubDate>
    <dc:creator>sk007</dc:creator>
    <dc:date>2022-06-03T10:52:20Z</dc:date>
    <item>
      <title>Calculate new column based on multiple conditions from two different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557628#M72670</link>
      <description>&lt;P&gt;I have two tables: Table1 (pay_frequency, ded_date) and Table2(Date, if_work_day).&lt;/P&gt;&lt;P&gt;Table1&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Table2&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Required Solution:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate a new column (required_date) like this:&lt;/P&gt;&lt;P&gt;if Table1[pay_frequency]="BI_WEEKLY" and Table1[pay_frequency]="WEEKLY":&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if Table2[if_work_day]=0:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;required_date = Table1[ded_date]+next date with if_work_day = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; required_date = Table1[ded_date]&lt;/P&gt;&lt;P&gt;if Table1[pay_frequency]="SEMI_MONTHLY" and Table1[pay_frequency]="MONTHLY":&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if Table2[if_work_day]=0:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;required_date = Table1[ded_date] - previous date with if_work_day = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; required_date = Table1[ded_date]&lt;/P&gt;&lt;P&gt;How to do this in PowerBI?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 10:50:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557628#M72670</guid>
      <dc:creator>sk007</dc:creator>
      <dc:date>2022-06-03T10:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate new column based on multiple conditions from two different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557652#M72673</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="323791" data-lia-user-login="sk007" class="lia-mention lia-mention-user"&gt;sk007&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Can you explain these two lines please? Also, confirm if you have any relationship between a Dates table and these two tables&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;required_date = Table1[ded_date]+next date with if_work_day = 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;required_date = Table1[ded_date] - previous date with if_work_day = 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 10:31:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557652#M72673</guid>
      <dc:creator>Fowmy</dc:creator>
      <dc:date>2022-06-03T10:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate new column based on multiple conditions from two different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557675#M72674</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="52518" data-lia-user-login="Fowmy" class="lia-mention lia-mention-user"&gt;Fowmy&lt;/a&gt;&amp;nbsp;yes i do have relationship between Table2 and Table1 (one to many). if_work_day = 0 means its a holiday, if_work_day =1 means its the working day.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;required_date = Table1[ded_date]+next date with if_work_day = 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;so when the if_work_day = 0, that means its a holiday. required_date shouldn't be on the holiday. for this one, it should be the next working day (if_work_day = 1) 1 means working day.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;required_date = Table1[ded_date] - previous date with if_work_day = 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;for this condition,&lt;/P&gt;&lt;P&gt;so when the if_work_day = 0, that means its a holiday. required_date shouldn't be on the holiday (if_work_day=0). for this one, it should be the previous working day (if_work_day = 1) 1 means working day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;let me know if this helps?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 10:39:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557675#M72674</guid>
      <dc:creator>sk007</dc:creator>
      <dc:date>2022-06-03T10:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate new column based on multiple conditions from two different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557703#M72677</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="323791" data-lia-user-login="sk007" class="lia-mention lia-mention-user"&gt;sk007&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Do you have a dates table connected to these two tables?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 10:51:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557703#M72677</guid>
      <dc:creator>Fowmy</dc:creator>
      <dc:date>2022-06-03T10:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate new column based on multiple conditions from two different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557706#M72678</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="52518" data-lia-user-login="Fowmy" class="lia-mention lia-mention-user"&gt;Fowmy&lt;/a&gt;&amp;nbsp;i've also added a screenshot of required solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 10:51:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557706#M72678</guid>
      <dc:creator>sk007</dc:creator>
      <dc:date>2022-06-03T10:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate new column based on multiple conditions from two different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557707#M72679</link>
      <description>&lt;P&gt;Table2 is the date table itself&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 10:52:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557707#M72679</guid>
      <dc:creator>sk007</dc:creator>
      <dc:date>2022-06-03T10:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate new column based on multiple conditions from two different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557821#M72685</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="323791" data-lia-user-login="sk007" class="lia-mention lia-mention-user"&gt;sk007&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Here is a sample file with the solution&amp;nbsp;&lt;A href="https://we.tl/t-ut86DgMNBs" target="_blank"&gt;https://we.tl/t-ut86DgMNBs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Is Work Day? = 
CALCULATE ( 
    SELECTEDVALUE ( Table2[if_work_day] ), 
    CROSSFILTER ( Table1[ded_date], Table2[Date], BOTH ) 
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;required_date = 
VAR CurrentPayFrequency = SELECTEDVALUE ( Table1[pay_frequency] )
VAR CurrentDate = MAX ( Table1[ded_date] )
VAR WorkingDates = FILTER ( Table2, Table2[if_work_day] = 1 )
VAR DatesBefore = FILTER ( WorkingDates, Table2[Date] &amp;lt;= CurrentDate )
VAR DatesAfter = FILTER ( WorkingDates, Table2[Date] &amp;gt;= CurrentDate )
VAR DateBefore = MAXX ( DatesBefore, Table2[Date] )
VAR DateAfter = MINX ( DatesAfter, Table2[Date] )
RETURN
    SWITCH (
        TRUE ( ),
        CurrentPayFrequency IN { "MONTHLY", "SEMI_MONTHLY" }, DateBefore,
        CurrentPayFrequency IN { "WEEKLY", "BI_WEEKLY" }, DateAfter
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 12:07:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-new-column-based-on-multiple-conditions-from-two/m-p/2557821#M72685</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-06-03T12:07:23Z</dc:date>
    </item>
  </channel>
</rss>

