<?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: Using existing data in one column to calculate a delta value in another column with DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3653480#M141544</link>
    <description>&lt;P&gt;-&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2024 08:59:19 GMT</pubDate>
    <dc:creator>Murten</dc:creator>
    <dc:date>2024-01-23T08:59:19Z</dc:date>
    <item>
      <title>Using existing data in one column to calculate a delta value in another column with DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3651934#M141475</link>
      <description>&lt;P&gt;Hi there&lt;BR /&gt;&lt;BR /&gt;So I have a dataset with 2 columns: "Timestamp" and "NumericValue"&lt;BR /&gt;&lt;BR /&gt;My objective is to create a new column which uses DAX to calculate the change in NumericValue. It should obviously start off with the earliest timestamp date and calculate based off previous value in NumericValue. As new numbers are added continously the logic should be generic and work automatically.&lt;BR /&gt;To give context i want to calculate the change of water consumption coming from an IoT water sensor only providing the meter (accumulated total consumption)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My table "Measurements" with examples:&lt;BR /&gt;| Timestamp&amp;nbsp; &amp;nbsp; | NumericValue | Delta_Value |&lt;BR /&gt;|--------------- |------------------|---------------|&lt;BR /&gt;| 2024-01-01&amp;nbsp; &amp;nbsp;| 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;BR /&gt;| 2024-01-02&amp;nbsp; &amp;nbsp;| 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;BR /&gt;| 2024-01-03&amp;nbsp; &amp;nbsp;| 15&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;BR /&gt;| 2024-01-04&amp;nbsp; &amp;nbsp;| 16&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;BR /&gt;etc etc&lt;BR /&gt;&lt;BR /&gt;I have tried a lot including chatgpt suggestions, but it doesn't really work. I made with work in Javascript, but i really want it to work using DAX&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 14:54:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3651934#M141475</guid>
      <dc:creator>Murten</dc:creator>
      <dc:date>2024-01-22T14:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using existing data in one column to calculate a delta value in another column with DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3652121#M141487</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file, that is for creating a calculated column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Delta_value CC =
VAR _previousvalue =
    SUMX (
        OFFSET (
            -1,
            Data,
            ORDERBY ( Data[Timestamp], ASC ),
            ,
            ,
            MATCHBY ( Data[Timestamp] )
        ),
        Data[NumericValue]
    )
RETURN
    IF ( NOT ISBLANK ( _previousvalue ), Data[NumericValue] - _previousvalue, 0 )
&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 Jan 2024 16:24:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3652121#M141487</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-01-22T16:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using existing data in one column to calculate a delta value in another column with DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3653418#M141540</link>
      <description>&lt;P&gt;Hi there&lt;BR /&gt;&lt;BR /&gt;Thank you for the suggestion. However i get this error (translated); &lt;EM&gt;"Even if MatchBy columns are specified, duplicate rows are detected in the Relation parameter of OFFSET. This is not allowed."&lt;/EM&gt;&lt;BR /&gt;- There are obviously duplicates in the NumericValue column, but that happens when the sensor doesn't register any new consumption = meter is not moving/counting&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;OK i may know what the issue is, but now how to fix it...&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So i guess timestamp will have duplicates as I also have columns "deviceId" and "field" with 4 different but constant values, where each value has their own row of timestamp, value etc... So 4x same timestamp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Yes, this is coming from a NoSQL db....&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;So maybe I need to also filter by only one of the four variables somehow?&lt;BR /&gt;&lt;BR /&gt;This is my code based on your suggestion:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Delta_heat = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; _previousvalue =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SUMX&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;OFFSET&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; &amp;nbsp; &amp;nbsp; -&lt;/SPAN&gt;&lt;SPAN&gt;1&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; &amp;nbsp; &amp;nbsp; Measurements,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ORDERBY&lt;/SPAN&gt;&lt;SPAN&gt; ( Measurements[timestamp], &lt;/SPAN&gt;&lt;SPAN&gt;ASC&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; &amp;nbsp; &amp;nbsp; ,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;MATCHBY&lt;/SPAN&gt;&lt;SPAN&gt; ( Measurements[timestamp] )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Measurements[numericValue]&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;NOT&lt;/SPAN&gt; &lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt; ( _previousvalue ), Measurements[numericValue] - _previousvalue, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Jan 2024 08:58:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3653418#M141540</guid>
      <dc:creator>Murten</dc:creator>
      <dc:date>2024-01-23T08:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using existing data in one column to calculate a delta value in another column with DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3653480#M141544</link>
      <description>&lt;P&gt;-&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 08:59:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3653480#M141544</guid>
      <dc:creator>Murten</dc:creator>
      <dc:date>2024-01-23T08:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using existing data in one column to calculate a delta value in another column with DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3653550#M141547</link>
      <description>&lt;P&gt;&amp;nbsp;-&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 08:59:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-existing-data-in-one-column-to-calculate-a-delta-value-in/m-p/3653550#M141547</guid>
      <dc:creator>Murten</dc:creator>
      <dc:date>2024-01-23T08:59:04Z</dc:date>
    </item>
  </channel>
</rss>

