<?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 DAX measure to replace large calculated table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4390055#M174279</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with contact person history. Each row represents a change in the status of my contact person. For example it shows that person a got status 'Approved' on 01-01-2025, on another row it shows that the same person got status 'Disapproved' at 31-01-2025. I want to visualize the amount of contact persons per status over time, but the issue is that the data only tells me something for 01-01-2025 and 31-01-2025 and not the dates inbetween.&lt;BR /&gt;&lt;BR /&gt;The solution I use for this now is a calculated table, but it returns millions of rows, which impacts the performance. Let me explain the solution:&lt;BR /&gt;1. Create calculated column in table&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;EndDate =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;NextDate&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ALLEXCEPT&lt;/SPAN&gt;&lt;SPAN&gt;(ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;, ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;[ContactId]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;EARLIER&lt;/SPAN&gt;&lt;SPAN&gt;(ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;NextDate&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;TODAY&lt;/SPAN&gt;&lt;SPAN&gt;(), &lt;/SPAN&gt;&lt;SPAN&gt;NextDate&lt;/SPAN&gt;&lt;SPAN&gt; - &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;2. Create a calculated table&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Contactpersoongeschiedenis per day =&lt;/SPAN&gt; &lt;SPAN&gt;GENERATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Contactpersoongeschiedenis&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;CALENDAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Contactpersoongeschiedenis&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;Contactpersoongeschiedenis&lt;/SPAN&gt;&lt;SPAN&gt;[EndDate]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;The solution works but i'm sure there's a better one that does not impact my performance as much.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 31 Jan 2025 14:25:02 GMT</pubDate>
    <dc:creator>BBConsultancy</dc:creator>
    <dc:date>2025-01-31T14:25:02Z</dc:date>
    <item>
      <title>DAX measure to replace large calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4390055#M174279</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with contact person history. Each row represents a change in the status of my contact person. For example it shows that person a got status 'Approved' on 01-01-2025, on another row it shows that the same person got status 'Disapproved' at 31-01-2025. I want to visualize the amount of contact persons per status over time, but the issue is that the data only tells me something for 01-01-2025 and 31-01-2025 and not the dates inbetween.&lt;BR /&gt;&lt;BR /&gt;The solution I use for this now is a calculated table, but it returns millions of rows, which impacts the performance. Let me explain the solution:&lt;BR /&gt;1. Create calculated column in table&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;EndDate =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;NextDate&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ALLEXCEPT&lt;/SPAN&gt;&lt;SPAN&gt;(ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;, ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;[ContactId]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;EARLIER&lt;/SPAN&gt;&lt;SPAN&gt;(ContactpersonHistory&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;NextDate&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;TODAY&lt;/SPAN&gt;&lt;SPAN&gt;(), &lt;/SPAN&gt;&lt;SPAN&gt;NextDate&lt;/SPAN&gt;&lt;SPAN&gt; - &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;2. Create a calculated table&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Contactpersoongeschiedenis per day =&lt;/SPAN&gt; &lt;SPAN&gt;GENERATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Contactpersoongeschiedenis&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;CALENDAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Contactpersoongeschiedenis&lt;/SPAN&gt;&lt;SPAN&gt;[CreatedDate]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;Contactpersoongeschiedenis&lt;/SPAN&gt;&lt;SPAN&gt;[EndDate]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;The solution works but i'm sure there's a better one that does not impact my performance as much.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 31 Jan 2025 14:25:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4390055#M174279</guid>
      <dc:creator>BBConsultancy</dc:creator>
      <dc:date>2025-01-31T14:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure to replace large calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4390059#M174280</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="692566" data-lia-user-login="BBConsultancy" class="lia-mention lia-mention-user"&gt;BBConsultancy&lt;/a&gt;&amp;nbsp;Create a measure to calculate the number of contact persons per status on a given date:&lt;/P&gt;
&lt;P&gt;ContactPersonsPerStatus = &lt;BR /&gt;VAR SelectedDate = MAX('Calendar'[Date])&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS(ContactpersonHistory),&lt;BR /&gt;FILTER(&lt;BR /&gt;ContactpersonHistory,&lt;BR /&gt;ContactpersonHistory[CreatedDate] &amp;lt;= SelectedDate &amp;amp;&amp;amp;&lt;BR /&gt;(ISBLANK(ContactpersonHistory[EndDate]) || ContactpersonHistory[EndDate] &amp;gt;= SelectedDate)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a measure to calculate the number of contact persons per status over time:&lt;/P&gt;
&lt;P&gt;DAX&lt;BR /&gt;ContactPersonsPerStatusOverTime = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;[ContactPersonsPerStatus],&lt;BR /&gt;DATESBETWEEN(&lt;BR /&gt;'Calendar'[Date],&lt;BR /&gt;MIN('Calendar'[Date]),&lt;BR /&gt;MAX('Calendar'[Date])&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 14:27:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4390059#M174280</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2025-01-31T14:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure to replace large calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4390131#M174281</link>
      <description>&lt;P&gt;Thanks for the fast reply. Unfortunately it does not work.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Left is your solution, and right is the expected result. It looks like left isn't accumulating over time.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 14:43:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4390131#M174281</guid>
      <dc:creator>BBConsultancy</dc:creator>
      <dc:date>2025-01-31T14:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure to replace large calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4390670#M174307</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="692566" data-lia-user-login="BBConsultancy" class="lia-mention lia-mention-user"&gt;BBConsultancy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-pm-slice="0 0 []"&gt;Your current approach using a calculated table with a daily row for each status is correct conceptually, but it generates a huge number of rows, which can significantly slow down your Power BI model. Instead of materializing all intermediate dates into a calculated table, you can calculate the active status per day dynamically using a measure.&lt;/P&gt;
&lt;P data-pm-slice="0 0 []"&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Active Contacts =
VAR SelectedDate = MAX('Calendar'[Date]) -- Get the current date in context
RETURN
CALCULATE(
    DISTINCTCOUNT(ContactpersonHistory[ContactId]), 
    ContactpersonHistory[CreatedDate] &amp;lt;= SelectedDate &amp;amp;&amp;amp; 
    ContactpersonHistory[EndDate] &amp;gt;= SelectedDate
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to &lt;STRONG&gt;split by status&lt;/STRONG&gt;, you can extend the measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Active Contacts per Status =
VAR SelectedDate = MAX('Calendar'[Date]) 
RETURN
CALCULATE(
    DISTINCTCOUNT(ContactpersonHistory[ContactId]),
    ContactpersonHistory[CreatedDate] &amp;lt;= SelectedDate &amp;amp;&amp;amp;
    ContactpersonHistory[EndDate] &amp;gt;= SelectedDate,
    VALUES(ContactpersonHistory[Status]) -- Ensure status is correctly grouped
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2025 04:55:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4390670#M174307</guid>
      <dc:creator>Poojara_D12</dc:creator>
      <dc:date>2025-02-01T04:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure to replace large calculated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4392072#M174353</link>
      <description>&lt;P&gt;Thank you for your reply, but unfortunately it does not work yet. I think it has something to do with the relationships to the date table, since I cannot have two active relations with both CreatedDate and EndDate, to the date table.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 08:49:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-to-replace-large-calculated-table/m-p/4392072#M174353</guid>
      <dc:creator>BBConsultancy</dc:creator>
      <dc:date>2025-02-03T08:49:40Z</dc:date>
    </item>
  </channel>
</rss>

