<?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 Using Calculate function with two tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-Calculate-function-with-two-tables/m-p/3607194#M139364</link>
    <description>&lt;P&gt;hi guys,&lt;/P&gt;&lt;P&gt;I'm struggling with the following problem:&lt;/P&gt;&lt;P&gt;I have two tables:&lt;/P&gt;&lt;P&gt;1. projects table. each row represents a project that has a "start date" and "End date"&lt;/P&gt;&lt;P&gt;2. regular calendar table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a column to the calendar table that calculates how many active projects were on this day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;tried to work with a straightforward calculate function but got the same result for each date:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;Active Projects =&lt;BR /&gt;VAR S_date = SELECTEDVALUE('Calendar Table'[Date])&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; calculate(&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; COUNTROWS(project table),&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILTER(project table,&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; project table[start date] &amp;lt;= S_date &amp;nbsp;&amp;amp;&amp;amp; project table[end date]&amp;gt;=S_date))&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;what am I missing here? thanks in advance folks&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 29 Dec 2023 13:28:03 GMT</pubDate>
    <dc:creator>SS0101</dc:creator>
    <dc:date>2023-12-29T13:28:03Z</dc:date>
    <item>
      <title>Using Calculate function with two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-Calculate-function-with-two-tables/m-p/3607194#M139364</link>
      <description>&lt;P&gt;hi guys,&lt;/P&gt;&lt;P&gt;I'm struggling with the following problem:&lt;/P&gt;&lt;P&gt;I have two tables:&lt;/P&gt;&lt;P&gt;1. projects table. each row represents a project that has a "start date" and "End date"&lt;/P&gt;&lt;P&gt;2. regular calendar table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a column to the calendar table that calculates how many active projects were on this day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;tried to work with a straightforward calculate function but got the same result for each date:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;Active Projects =&lt;BR /&gt;VAR S_date = SELECTEDVALUE('Calendar Table'[Date])&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; calculate(&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; COUNTROWS(project table),&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILTER(project table,&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; project table[start date] &amp;lt;= S_date &amp;nbsp;&amp;amp;&amp;amp; project table[end date]&amp;gt;=S_date))&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;what am I missing here? thanks in advance folks&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 29 Dec 2023 13:28:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-Calculate-function-with-two-tables/m-p/3607194#M139364</guid>
      <dc:creator>SS0101</dc:creator>
      <dc:date>2023-12-29T13:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate function with two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-Calculate-function-with-two-tables/m-p/3608594#M139461</link>
      <description>&lt;P&gt;You would need to inactivate the relationship between the calendar table and the projects table. Then for your visual use the date from the calendar table for the axis and your measure as the data.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 22:06:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-Calculate-function-with-two-tables/m-p/3608594#M139461</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-12-30T22:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate function with two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-Calculate-function-with-two-tables/m-p/3609490#M139523</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="521869" data-lia-user-login="SS0101" class="lia-mention lia-mention-user"&gt;SS0101&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try the following measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
var _select=SELECTEDVALUE('Calendar Table'[Date])
return
COUNTX(
    FILTER(ALL('projects table'),
    _select&amp;gt;='projects table'[StartDate]&amp;amp;&amp;amp;_select&amp;lt;='projects table'[EndDate]),[project])&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Or add an ALL() function to the original Dax.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/all-function-dax" target="_blank"&gt;ALL function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If it doesn't meet your desired outcome, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jan 2024 08:24:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-Calculate-function-with-two-tables/m-p/3609490#M139523</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-01T08:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate function with two tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-Calculate-function-with-two-tables/m-p/3622266#M140078</link>
      <description>&lt;P&gt;thanks Liu Yang!&lt;/P&gt;&lt;P&gt;that nearly solved my issues, however - In this setup, I can't use any slicer (doesn't have any effect). is it due to the ALL command? how can it be worked around?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 10:24:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-Calculate-function-with-two-tables/m-p/3622266#M140078</guid>
      <dc:creator>SS0101</dc:creator>
      <dc:date>2024-01-08T10:24:34Z</dc:date>
    </item>
  </channel>
</rss>

