<?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 Fifo Stock  cost - Multiple Tables &amp;amp; Products &amp;amp; Same dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fifo-Stock-cost-Multiple-Tables-amp-Products-amp-Same-dates/m-p/1725727#M35721</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have been reading a lot of articles about FIFO stock valuation.&amp;nbsp;&lt;BR /&gt;I have mainly followed the following one:&amp;nbsp;&lt;A href="https://radacad.com/dax-inventory-or-stock-valuation-using-fifo" target="_blank"&gt;https://radacad.com/dax-inventory-or-stock-valuation-using-fifo&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The particular situation I have is that I have 2 different tables. One for the sales operations and one for the buy operations.&lt;/P&gt;&lt;P&gt;To solve the only 1 operation per day limit, I used an index column in each table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No the problem is where I calculate the FIFO column. When I declare the variable it is not accepted and I have different errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FIFO = 
VAR myCurrentSell = Hoja1[Cantidad Acumulada]
VAR myLastSell = Hoja1[Cantidad acumulada anterior]
VAR mySymbol = Hoja1[Artículo]
VAR myCumulativeBuy = FIRSTNONBLANKVALUE(Transferencias[Kg Acumulados],FILTER(Transferencias, mySymbol))
VAR myLastCumulativeBuy = FIRSTNONBLANKVALUE(Transferencias[Kg Acumulados Anteriores],FILTER(Transferencias, mySymbol))
VAR FIFOFilterTable =
    FILTER (
        Transferencias,
        Transferencias[Producto] = mySymbol
            &amp;amp;&amp;amp; ( ( Transferencias[Kg Acumulados] &amp;gt;= myLastSell
            &amp;amp;&amp;amp; Transferencias[Kg Acumulados] &amp;lt; myCurrentSell )
            || Transferencias[Kg Acumulados] &amp;gt;= myCurrentSell
            &amp;amp;&amp;amp; Transferencias[Kg Acumulados Anteriores] &amp;lt; myCurrentSell
            || Transferencias[Kg Acumulados Anteriores]  &amp;gt; myLastCumulativeBuy
            &amp;amp;&amp;amp; Transferencias[Kg Acumulados] &amp;lt; myLastCumulativeBuy )
    )
VAR FilteredFIFOTable =
    ADDCOLUMNS (
        FIFOFilterTable,
        "New Value", SWITCH (
            TRUE (),
            Transferencias[Kg Acumulados] &amp;gt; myLastSell
                &amp;amp;&amp;amp; Transferencias[Kg Acumulados Anteriores] &amp;lt; myLastSell, Hoja1[cantidad]
                - ( myLastSell - Transferencias[Kg Acumulados Anteriores] ),
            Transferencias[Kg Acumulados] &amp;lt; myCurrentSell, Hoja1[cantidad],
            -- ELSE --
            Hoja1[cantidad]
                - ( Transferencias[Kg Acumulados] - myCurrentSell )
        )
    )
RETURN
    Related(Transferencias[Costo Total])
        - SUMX ( FilteredFIFOTable, [New Value] * related(Transferencias[Costo Unitario])
)&lt;/LI-CODE&gt;&lt;P&gt;The column fifo is made on the "Sales" table. (Of course I need to know the cost of each sale).&lt;/P&gt;&lt;P&gt;When I declare the variable mycumulativebuy and mypreviouscumulativebuy, it doesn't recognize the relationship with the other table. I tried to use other ways to declare it (hence the function that you can see in the code) but the error it comes is "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;pablo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Mar 2021 17:33:01 GMT</pubDate>
    <dc:creator>pwagma</dc:creator>
    <dc:date>2021-03-16T17:33:01Z</dc:date>
    <item>
      <title>Fifo Stock  cost - Multiple Tables &amp; Products &amp; Same dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fifo-Stock-cost-Multiple-Tables-amp-Products-amp-Same-dates/m-p/1725727#M35721</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have been reading a lot of articles about FIFO stock valuation.&amp;nbsp;&lt;BR /&gt;I have mainly followed the following one:&amp;nbsp;&lt;A href="https://radacad.com/dax-inventory-or-stock-valuation-using-fifo" target="_blank"&gt;https://radacad.com/dax-inventory-or-stock-valuation-using-fifo&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The particular situation I have is that I have 2 different tables. One for the sales operations and one for the buy operations.&lt;/P&gt;&lt;P&gt;To solve the only 1 operation per day limit, I used an index column in each table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No the problem is where I calculate the FIFO column. When I declare the variable it is not accepted and I have different errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FIFO = 
VAR myCurrentSell = Hoja1[Cantidad Acumulada]
VAR myLastSell = Hoja1[Cantidad acumulada anterior]
VAR mySymbol = Hoja1[Artículo]
VAR myCumulativeBuy = FIRSTNONBLANKVALUE(Transferencias[Kg Acumulados],FILTER(Transferencias, mySymbol))
VAR myLastCumulativeBuy = FIRSTNONBLANKVALUE(Transferencias[Kg Acumulados Anteriores],FILTER(Transferencias, mySymbol))
VAR FIFOFilterTable =
    FILTER (
        Transferencias,
        Transferencias[Producto] = mySymbol
            &amp;amp;&amp;amp; ( ( Transferencias[Kg Acumulados] &amp;gt;= myLastSell
            &amp;amp;&amp;amp; Transferencias[Kg Acumulados] &amp;lt; myCurrentSell )
            || Transferencias[Kg Acumulados] &amp;gt;= myCurrentSell
            &amp;amp;&amp;amp; Transferencias[Kg Acumulados Anteriores] &amp;lt; myCurrentSell
            || Transferencias[Kg Acumulados Anteriores]  &amp;gt; myLastCumulativeBuy
            &amp;amp;&amp;amp; Transferencias[Kg Acumulados] &amp;lt; myLastCumulativeBuy )
    )
VAR FilteredFIFOTable =
    ADDCOLUMNS (
        FIFOFilterTable,
        "New Value", SWITCH (
            TRUE (),
            Transferencias[Kg Acumulados] &amp;gt; myLastSell
                &amp;amp;&amp;amp; Transferencias[Kg Acumulados Anteriores] &amp;lt; myLastSell, Hoja1[cantidad]
                - ( myLastSell - Transferencias[Kg Acumulados Anteriores] ),
            Transferencias[Kg Acumulados] &amp;lt; myCurrentSell, Hoja1[cantidad],
            -- ELSE --
            Hoja1[cantidad]
                - ( Transferencias[Kg Acumulados] - myCurrentSell )
        )
    )
RETURN
    Related(Transferencias[Costo Total])
        - SUMX ( FilteredFIFOTable, [New Value] * related(Transferencias[Costo Unitario])
)&lt;/LI-CODE&gt;&lt;P&gt;The column fifo is made on the "Sales" table. (Of course I need to know the cost of each sale).&lt;/P&gt;&lt;P&gt;When I declare the variable mycumulativebuy and mypreviouscumulativebuy, it doesn't recognize the relationship with the other table. I tried to use other ways to declare it (hence the function that you can see in the code) but the error it comes is "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;pablo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 17:33:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fifo-Stock-cost-Multiple-Tables-amp-Products-amp-Same-dates/m-p/1725727#M35721</guid>
      <dc:creator>pwagma</dc:creator>
      <dc:date>2021-03-16T17:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fifo Stock  cost - Multiple Tables &amp; Products &amp; Same dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fifo-Stock-cost-Multiple-Tables-amp-Products-amp-Same-dates/m-p/1761509#M36855</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291048" data-lia-user-login="pwagma" class="lia-mention lia-mention-user"&gt;pwagma&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;You may try&lt;BR /&gt;myCumulativeBuy =&amp;nbsp;&lt;BR /&gt;Firstnonblankvalue(Transferencias[kg acumulados], Filter(Transferencias, Transferencias = mysymbol))&lt;/P&gt;&lt;P&gt;Can you please provide the sample data and expected output?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 11:12:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Fifo-Stock-cost-Multiple-Tables-amp-Products-amp-Same-dates/m-p/1761509#M36855</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-02T11:12:14Z</dc:date>
    </item>
  </channel>
</rss>

