<?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 Help with DAX formula to calculate value from previous day in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-formula-to-calculate-value-from-previous-day/m-p/3333858#M125000</link>
    <description>&lt;P class=""&gt;I need to create a calculated column 'Inventory_value' that calculates for each PV/product/date the inventory as follows:&lt;/P&gt;&lt;P class=""&gt;The inventory of the day before for that PV/product + qty_em + qty_ref- qty_ven&lt;/P&gt;&lt;P class=""&gt;If the inventory of the day before is not present, it becomes 0.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;So far I've only made this and it doesn't work, because I always get a big value like as if its summing up all the rows together&lt;/P&gt;&lt;PRE&gt;inventory_value = 
var current_dt = rimanenze_pv_day_nonoil[dt]
var product = rimanenze_pv_day_nonoil[cost_prod]
var inventory_before =
    CALCULATE(
        SUM(rimanenze_pv_day_nonoil[em_total_value]),
        FILTER(
        rimanenze_pv_day_nonoil,
        rimanenze_pv_day_nonoil[dt] = current_dt - 1
        )
    )

var inventory_true = inventory_before + rimanenze_pv_day_nonoil[em_qty] + rimanenze_pv_day_nonoil[rett_qty] - rimanenze_pv_day_nonoil[ven_qty]

var result = 
    IF(
        ISBLANK(inventory_before),
        0,
        inventory_true
    )
return

result&lt;/PRE&gt;&lt;P class=""&gt;The idea is that it returns that sum for each row, not all summed together. Does anyone have a clue on how to fix this? All the values are within the same table.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jul 2023 08:06:28 GMT</pubDate>
    <dc:creator>ale_BI</dc:creator>
    <dc:date>2023-07-17T08:06:28Z</dc:date>
    <item>
      <title>Help with DAX formula to calculate value from previous day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-formula-to-calculate-value-from-previous-day/m-p/3333858#M125000</link>
      <description>&lt;P class=""&gt;I need to create a calculated column 'Inventory_value' that calculates for each PV/product/date the inventory as follows:&lt;/P&gt;&lt;P class=""&gt;The inventory of the day before for that PV/product + qty_em + qty_ref- qty_ven&lt;/P&gt;&lt;P class=""&gt;If the inventory of the day before is not present, it becomes 0.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;So far I've only made this and it doesn't work, because I always get a big value like as if its summing up all the rows together&lt;/P&gt;&lt;PRE&gt;inventory_value = 
var current_dt = rimanenze_pv_day_nonoil[dt]
var product = rimanenze_pv_day_nonoil[cost_prod]
var inventory_before =
    CALCULATE(
        SUM(rimanenze_pv_day_nonoil[em_total_value]),
        FILTER(
        rimanenze_pv_day_nonoil,
        rimanenze_pv_day_nonoil[dt] = current_dt - 1
        )
    )

var inventory_true = inventory_before + rimanenze_pv_day_nonoil[em_qty] + rimanenze_pv_day_nonoil[rett_qty] - rimanenze_pv_day_nonoil[ven_qty]

var result = 
    IF(
        ISBLANK(inventory_before),
        0,
        inventory_true
    )
return

result&lt;/PRE&gt;&lt;P class=""&gt;The idea is that it returns that sum for each row, not all summed together. Does anyone have a clue on how to fix this? All the values are within the same table.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 08:06:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-formula-to-calculate-value-from-previous-day/m-p/3333858#M125000</guid>
      <dc:creator>ale_BI</dc:creator>
      <dc:date>2023-07-17T08:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with DAX formula to calculate value from previous day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-formula-to-calculate-value-from-previous-day/m-p/3333926#M125002</link>
      <description>&lt;P&gt;you did not define the product?&lt;/P&gt;
&lt;PRE&gt;inventory_value = 
var current_dt = rimanenze_pv_day_nonoil[dt]
var product = rimanenze_pv_day_nonoil[cost_prod]
var inventory_before =
    CALCULATE(
        SUM(rimanenze_pv_day_nonoil[em_total_value]),
        FILTER(
        rimanenze_pv_day_nonoil,&lt;BR /&gt;        &lt;FONT size="5"&gt;rimanenze_pv_day_nonoil[cost_prod]=product,&lt;/FONT&gt;
        rimanenze_pv_day_nonoil[dt] = current_dt - 1
        )
    )

var inventory_true = inventory_before + rimanenze_pv_day_nonoil[em_qty] + rimanenze_pv_day_nonoil[rett_qty] - rimanenze_pv_day_nonoil[ven_qty]

var result = 
    IF(
        ISBLANK(inventory_before),
        0,
        inventory_true
    )
return

result&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2023 08:51:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-formula-to-calculate-value-from-previous-day/m-p/3333926#M125002</guid>
      <dc:creator>wdx223_Daniel</dc:creator>
      <dc:date>2023-07-17T08:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help with DAX formula to calculate value from previous day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-formula-to-calculate-value-from-previous-day/m-p/3333985#M125006</link>
      <description>&lt;P&gt;Thank you, I used the additional detail as an AND measure like so&lt;BR /&gt;&lt;BR /&gt;&lt;/P&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;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;rimanenze_pv_day_nonoil&lt;/SPAN&gt;&lt;SPAN&gt;[em_total_value]&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;FILTER&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;rimanenze_pv_day_nonoil&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;rimanenze_pv_day_nonoil&lt;/SPAN&gt;&lt;SPAN&gt;[dt]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;current_dt&lt;/SPAN&gt;&lt;SPAN&gt; - &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;rimanenze_pv_day_nonoil&lt;/SPAN&gt;&lt;SPAN&gt;[cost_prod]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;product&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; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am not sure if this works, I will need to check thoroughly, but it does indeed give me more plausible results.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 17 Jul 2023 09:24:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-DAX-formula-to-calculate-value-from-previous-day/m-p/3333985#M125006</guid>
      <dc:creator>ale_BI</dc:creator>
      <dc:date>2023-07-17T09:24:12Z</dc:date>
    </item>
  </channel>
</rss>

