<?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: mixing calculated columns and measures in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/mixing-calculated-columns-and-measures/m-p/1586381#M31763</link>
    <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Correction. My bad. I reported a remaining issue but that was because I had an error in my measure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Op0-60 = var _max = maxx(allselected(TDates), TDates[RefDate].[Date])&lt;/P&gt;&lt;P&gt;return sumX(filter(values(Invoices), datediff(max(Invoices[InvoiceDate]), _max,day)&amp;lt;=60), Invoices[OpenPosition])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;should have been&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Op0-60 = var _max = maxx(allselected(TDates), TDates[RefDate].[Date])&lt;/P&gt;&lt;P&gt;return sumX(filter(values(Invoices), datediff(Invoices[InvoiceDate], _max,day)&amp;lt;=60), Invoices[OpenPosition])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;note the removed MAX() in the first datediff parameter. Now it works like a charm!! Thank you for your help.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jan 2021 14:07:03 GMT</pubDate>
    <dc:creator>RudyL</dc:creator>
    <dc:date>2021-01-07T14:07:03Z</dc:date>
    <item>
      <title>mixing calculated columns and measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/mixing-calculated-columns-and-measures/m-p/1584195#M31671</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I hope this link (&lt;A href="https://wetransfer.com/downloads/cbb9aecbf31a3a212a14a81988e7875c20210106102742/1a6fc91957cc4d7008662f4323bef92820210106102803/276199%20" target="_blank"&gt;example_pbix_on_wetransfer&lt;/A&gt;&amp;nbsp;) still works. It has the pbix with my challenge.&lt;/P&gt;&lt;P&gt;I have a simplified invoices table (fig1). I linked the transdate with a datetable and added a slicer to the report on the date table. This way I managed to use the date table as a reference date to show only the invoices and payments before a certain date. I can then calculate the Openposition on a certain date (for example march-2-2020) through&amp;nbsp;OpenPosition = Invoices[Invoiced]-Invoices[Paid], (see fig2).&lt;/P&gt;&lt;P&gt;I want to use the same reference date to determine the status of an invoice on the given date instead of using the NOW() to present the results. So I made a measure that returns the number of days from the invoicedate and the reference date (see fig2)&lt;/P&gt;&lt;P&gt;Due2Ref = var _max = maxx(allselected(TDates), TDates[RefDate].[Date])&lt;/P&gt;&lt;P&gt;return averageX(values(Invoices), datediff(max(Invoices[InvoiceDate]),_max,day))&lt;/P&gt;&lt;P&gt;But now the struggle begins. I want to see how much is unpaid &amp;nbsp;that should have been paid less than 60 days ago and how much is unpaid that should have been paid more than 90 days ago, RELATIVE TO THE REFERENCE DATE!&lt;/P&gt;&lt;P&gt;It’s straightforward to use a calculated column, and this one works when I use NOW() as a reference date. (fig2). But I don’t want the opendays calculated from NOW() but from the reference date. And then the mixing of measures and calculated columns begins. How do I change the open0-60 column that it uses the reference date?&lt;/P&gt;&lt;P&gt;Open0-60 = if(now() &amp;gt;= Invoices[InvoiceDate].[Date] &amp;amp;&amp;amp; now()&amp;lt;=Invoices[InvoiceDate].[Date]+60,Invoices[OpenPosition],0)&lt;/P&gt;&lt;P&gt;In the fig2-example 200 from Invoice I1 should remain on open60plus, but 200+1000 from I2 and I3 should move to open0-60 and the total open0-60 should become 1200 while total open60 plus would be 200.&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;&lt;P&gt;fig1.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;fig2&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 11:06:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/mixing-calculated-columns-and-measures/m-p/1584195#M31671</guid>
      <dc:creator>RudyL</dc:creator>
      <dc:date>2021-01-06T11:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: mixing calculated columns and measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/mixing-calculated-columns-and-measures/m-p/1584232#M31672</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="176379" data-lia-user-login="RudyL" class="lia-mention lia-mention-user"&gt;RudyL&lt;/a&gt; , Please check something like this can work?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Due2Ref = var _max = maxx(allselected(TDates), TDates[RefDate].[Date])&lt;/P&gt;
&lt;P&gt;return averageX(filter(values(Invoices),datediff(max(Invoices[InvoiceDate]),_max,day)&amp;lt;=60), datediff(max(Invoices[InvoiceDate]),_max,day))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can think of dynamic segmentation&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=CuczXPj0N-k&amp;amp;t=398s" target="_blank"&gt;https://www.youtube.com/watch?v=CuczXPj0N-k&amp;amp;t=398s&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 11:18:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/mixing-calculated-columns-and-measures/m-p/1584232#M31672</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-01-06T11:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: mixing calculated columns and measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/mixing-calculated-columns-and-measures/m-p/1584603#M31695</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Almost. I changed your suggestion to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Op0-60 = var _max = maxx(allselected(TDates), TDates[RefDate].[Date])&lt;/P&gt;&lt;P&gt;return sumX(filter(values(Invoices),datediff(max(Invoices[InvoiceDate]),_max,day)&amp;lt;=60), Invoices[OpenPosition])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the same for op60plus to get an almost perfect result. It adds the right numbers on a line level, but in the totals the measures go out of control and they add 1000+200 to 1400 and 200+0 to blank. Is there some solution to make the totals correct as well?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 14:37:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/mixing-calculated-columns-and-measures/m-p/1584603#M31695</guid>
      <dc:creator>RudyL</dc:creator>
      <dc:date>2021-01-06T14:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: mixing calculated columns and measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/mixing-calculated-columns-and-measures/m-p/1586381#M31763</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Correction. My bad. I reported a remaining issue but that was because I had an error in my measure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Op0-60 = var _max = maxx(allselected(TDates), TDates[RefDate].[Date])&lt;/P&gt;&lt;P&gt;return sumX(filter(values(Invoices), datediff(max(Invoices[InvoiceDate]), _max,day)&amp;lt;=60), Invoices[OpenPosition])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;should have been&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Op0-60 = var _max = maxx(allselected(TDates), TDates[RefDate].[Date])&lt;/P&gt;&lt;P&gt;return sumX(filter(values(Invoices), datediff(Invoices[InvoiceDate], _max,day)&amp;lt;=60), Invoices[OpenPosition])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;note the removed MAX() in the first datediff parameter. Now it works like a charm!! Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 14:07:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/mixing-calculated-columns-and-measures/m-p/1586381#M31763</guid>
      <dc:creator>RudyL</dc:creator>
      <dc:date>2021-01-07T14:07:03Z</dc:date>
    </item>
  </channel>
</rss>

