<?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 Measure with cross filter in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2245666#M53902</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a question on creating a measure, taking into account multiple tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;In one table ("Date-table") I have a set of data, with a row for each date between 2015 and 2025. This table contains a column with an logical indicator whether the date in row is a "Workday" or not.&lt;/LI&gt;&lt;LI&gt;In the other table ("Asset-table") I have a set of data on fixed assets. This table contains two interesting columns: Purchase date and Selling date&lt;P&gt;Now, I would like to have the number of "Workdays" per Fixed Asset (in order to calculate the occupancy rate afterwards). I now simply count:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Number of Workdays available = COUNTAX(FILTER('Date', Date[IsWorkDay]=TRUE()),TRUE())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;This works well, but it does not take into account that the asset can be bought or sold during the selected date range.&lt;DIV&gt;So, I am now looking for a solution (either in DAX or PowerQuery) in which I can combine these events.&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;I have now created a Crossjoin-table from both tables. I think I now have the complete set needed to ma&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;So I'm looking for something like this:&lt;/DIV&gt;&lt;DIV&gt;Number of Workdays available = COUNTAX(FILTER('Date', if(IsWorkday&amp;lt;= DateSold and IsWorkday &amp;gt;= DatePurchased),Date[IsWorkDay]=TRUE()),TRUE())&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Do you have any suggestion?&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Dec 2021 10:48:25 GMT</pubDate>
    <dc:creator>NickHoffmans</dc:creator>
    <dc:date>2021-12-18T10:48:25Z</dc:date>
    <item>
      <title>Measure with cross filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2245666#M53902</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a question on creating a measure, taking into account multiple tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;In one table ("Date-table") I have a set of data, with a row for each date between 2015 and 2025. This table contains a column with an logical indicator whether the date in row is a "Workday" or not.&lt;/LI&gt;&lt;LI&gt;In the other table ("Asset-table") I have a set of data on fixed assets. This table contains two interesting columns: Purchase date and Selling date&lt;P&gt;Now, I would like to have the number of "Workdays" per Fixed Asset (in order to calculate the occupancy rate afterwards). I now simply count:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Number of Workdays available = COUNTAX(FILTER('Date', Date[IsWorkDay]=TRUE()),TRUE())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;This works well, but it does not take into account that the asset can be bought or sold during the selected date range.&lt;DIV&gt;So, I am now looking for a solution (either in DAX or PowerQuery) in which I can combine these events.&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;I have now created a Crossjoin-table from both tables. I think I now have the complete set needed to ma&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;So I'm looking for something like this:&lt;/DIV&gt;&lt;DIV&gt;Number of Workdays available = COUNTAX(FILTER('Date', if(IsWorkday&amp;lt;= DateSold and IsWorkday &amp;gt;= DatePurchased),Date[IsWorkDay]=TRUE()),TRUE())&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Do you have any suggestion?&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 10:48:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2245666#M53902</guid>
      <dc:creator>NickHoffmans</dc:creator>
      <dc:date>2021-12-18T10:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with cross filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2245688#M53904</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="338222" data-lia-user-login="NickHoffmans" class="lia-mention lia-mention-user"&gt;NickHoffmans&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Number of Workdays available =
COUNTROWS(
    FILTER(
        'Date',
        'Date'[Date] &amp;lt;= DateSold
            &amp;amp;&amp;amp; 'Date'[Date] &amp;gt;= DatePurchased
            &amp;amp;&amp;amp; 'Date'[IsWorkDay] = TRUE()
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;helps, please consider&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;accepting&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN&gt;Appreciate your Kudos!!&lt;BR /&gt;&lt;STRONG&gt;LinkedIn:&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://www.linkedin.com/in/vahid-dm/" target="_blank" rel="noopener"&gt;www.linkedin.com/in/vahid-dm/&lt;/A&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 12:52:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2245688#M53904</guid>
      <dc:creator>VahidDM</dc:creator>
      <dc:date>2021-12-18T12:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with cross filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2245873#M53913</link>
      <description>&lt;P&gt;You could consider changing the structure of your data model to make the DAX easier and optimise the whole thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You want to end up with a factless fact table with columns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date, AssetId, OtherIds&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each asset then has a row for every day it is owned. Purchase date is the earliest row. Sale date is the last row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I came from an excel background this seemed alien as you end up with lots more rows but the engine can cope with it and if you keep it so you just store integer Ids from&lt;/P&gt;&lt;P&gt;dimension tables and a date the compression keeps things small and very fast.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lots of ways to achieve such a table but you could cross join your asset table with your date table in power query and then Filter out rows outside of date range. (&lt;A href="https://docs.microsoft.com/en-us/power-query/cross-join" target="_blank"&gt;https://docs.microsoft.com/en-us/power-query/cross-join&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 22:39:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2245873#M53913</guid>
      <dc:creator>bcdobbs</dc:creator>
      <dc:date>2021-12-18T22:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with cross filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2247652#M53991</link>
      <description>&lt;P&gt;Thanks. What is the difference between the crossjoin in DAX and the crossjoin in PowerQuery?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2021 13:09:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2247652#M53991</guid>
      <dc:creator>NickHoffmans</dc:creator>
      <dc:date>2021-12-20T13:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with cross filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2252876#M54329</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="338222" data-lia-user-login="NickHoffmans" class="lia-mention lia-mention-user"&gt;NickHoffmans&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;CROSSJOIN DAX :&lt;/SPAN&gt;&lt;/STRONG&gt; Returns a &lt;STRONG&gt;table&lt;/STRONG&gt; that contains the Cartesian product of all rows from all tables in the arguments. The columns in the new table are all the columns in all the argument tables.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Cross join Query : &lt;/STRONG&gt;A cross join is a type of join that returns the Cartesian product of rows from the tables in the join. In other words, it combines each row from the first table with each row from the second table.&lt;/P&gt;
&lt;P&gt;The difference is , &lt;STRONG&gt;&lt;SPAN&gt;CROSSJOIN DAX &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;create a new table to combine the two tables to one ,but &lt;/SPAN&gt;&lt;STRONG&gt;Cross join Query&lt;/STRONG&gt; is add a new column ,then expand the column .&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can learn more in the links below .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs.microsoft.com/en-us/dax/crossjoin-function-dax" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/dax/crossjoin-function-dax&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs.microsoft.com/en-us/power-query/cross-join" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/power-query/cross-join&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I also create a sample for you , you can refer to it .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regard&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Community Support Team _ Ailsa Tao&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 02:14:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-cross-filter/m-p/2252876#M54329</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-12-23T02:14:20Z</dc:date>
    </item>
  </channel>
</rss>

