<?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 calculate variance between two dates based on two values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-variance-between-two-dates-based-on-two-values/m-p/3106160#M109478</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables as per below, I need to calculate the difference between "daily sales" before and after the "Service" was done, using "Bsc Start" and "COM date". The only constant in both tables is the "Corporate ref", and for every date I have a "Daily sale" figure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg. I would need to say the Daily sale difference between Bsc Strat and COM date for the Service TA10, Corporate Ref z765 is xxx&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have tried a couple of options but its not working, I have 2 years worth of daily data and the Corporate Ref are repeating multiple times, same as Service.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can you please help me add this column?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Mar 2023 15:39:39 GMT</pubDate>
    <dc:creator>taylorie</dc:creator>
    <dc:date>2023-03-01T15:39:39Z</dc:date>
    <item>
      <title>calculate variance between two dates based on two values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-variance-between-two-dates-based-on-two-values/m-p/3106160#M109478</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables as per below, I need to calculate the difference between "daily sales" before and after the "Service" was done, using "Bsc Start" and "COM date". The only constant in both tables is the "Corporate ref", and for every date I have a "Daily sale" figure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg. I would need to say the Daily sale difference between Bsc Strat and COM date for the Service TA10, Corporate Ref z765 is xxx&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have tried a couple of options but its not working, I have 2 years worth of daily data and the Corporate Ref are repeating multiple times, same as Service.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can you please help me add this column?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 15:39:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-variance-between-two-dates-based-on-two-values/m-p/3106160#M109478</guid>
      <dc:creator>taylorie</dc:creator>
      <dc:date>2023-03-01T15:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: calculate variance between two dates based on two values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-variance-between-two-dates-based-on-two-values/m-p/3109612#M109769</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="522717" data-lia-user-login="taylorie" class="lia-mention lia-mention-user"&gt;taylorie&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, here are my steps you can follow as a solution.&lt;/P&gt;
&lt;P&gt;(1) My test data is the same as yours.&lt;/P&gt;
&lt;P&gt;(2) We can create a measure.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Variance = 
var a=MINX(FILTER(ALL('Table (2)'),[Corporate ref]=MAX('Table'[Corporate ref])&amp;amp;&amp;amp;[Date]&amp;gt;=MAX('Table'[Bsc start])),[Date])
var b=CALCULATE(SUM('Table (2)'[Daily sale]),'Table (2)'[Date]=a)
return ABS(CALCULATE(SUM('Table (2)'[Daily sale]),'Table (2)'[Date]=a+1)-b)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(3) Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 07:04:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-variance-between-two-dates-based-on-two-values/m-p/3109612#M109769</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-03T07:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: calculate variance between two dates based on two values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-variance-between-two-dates-based-on-two-values/m-p/3136899#M111840</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;Hi and thank you, I have applied the measure to my data but I noticed the COM date is not acounted for in this. I have cheched the data but its not working. see below from my tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the result&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This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&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'leakage data 2018'&lt;/SPAN&gt;&lt;SPAN&gt;[Daily Leakage (m³/d)]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;'leakage data 2018'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;ABS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'leakage data 2018'&lt;/SPAN&gt;&lt;SPAN&gt;[Daily Leakage (m³/d)]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;'leakage data 2018'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;)-&lt;/SPAN&gt;&lt;SPAN&gt;b&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I maybe missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 17:06:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-variance-between-two-dates-based-on-two-values/m-p/3136899#M111840</guid>
      <dc:creator>taylorie</dc:creator>
      <dc:date>2023-03-16T17:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: calculate variance between two dates based on two values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-variance-between-two-dates-based-on-two-values/m-p/3138054#M111920</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="522717" data-lia-user-login="taylorie" class="lia-mention lia-mention-user"&gt;taylorie&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try changing the column about dates to the same format. Please check the data model as shown in the following figure. If that doesn't help, can you provide a PBIX file (take care to protect your data privacy).&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 06:56:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-variance-between-two-dates-based-on-two-values/m-p/3138054#M111920</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-17T06:56:50Z</dc:date>
    </item>
  </channel>
</rss>

