<?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 Data Modelling in Catalog and Lineage</title>
    <link>https://community.qlik.com/t5/Catalog-and-Lineage/Data-Modelling/m-p/1769440#M538</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;Please find my code as below&lt;/P&gt;&lt;P&gt;Temp_Open:&lt;BR /&gt;LOAD&lt;BR /&gt;if(not WildMatch(Replace(LTrim(Replace(Material, '0',' ')),' ', '0'),'3*','4*'),&lt;BR /&gt;Replace(LTrim(Replace(Material, '0',' ')),' ', '0')) as Material,&lt;BR /&gt;'Inventory' as Spend_Type,&lt;BR /&gt;Plant,&lt;BR /&gt;"Opening Stock Qty",&lt;BR /&gt;Date(Date#("Trans. date", 'YYYYMMDD')) as Posting_Date_Stock&lt;BR /&gt;FROM path&lt;BR /&gt;(qvd) where Plant='N201' and Material='108000000021' ;&lt;/P&gt;&lt;P&gt;Concatenate(Consumption)&lt;BR /&gt;LOAD&lt;BR /&gt;Plant ,&lt;BR /&gt;Spend_Type,&lt;BR /&gt;Material ,&lt;BR /&gt;Posting_Date_Stock as Posting_Date ,&lt;BR /&gt;"Opening Stock Qty" as "Opening Stock Qty1"&lt;BR /&gt;Resident Temp_Open;&lt;BR /&gt;Drop Table Temp_Open;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/**************** Opening Stock Logic - Stage1 ****************/&lt;BR /&gt;qualify *;&lt;BR /&gt;NoConcatenate&lt;BR /&gt;Temp_OpenClose:&lt;BR /&gt;Load&lt;BR /&gt;%Key_OpenClose1 , Material , Plant , Posting_Date,&lt;BR /&gt;Sum( "Opening Stock Qty1" + Stock_Receipt - Stock_Issued) as Stock_Close,&lt;BR /&gt;Alt(Sum("Opening Stock Qty1"),0) as Stock_Open,&lt;BR /&gt;Sum (Stock_Issued) as Stock_Issued2,&lt;BR /&gt;Sum (Stock_Receipt) as Stock_Receipt2&lt;BR /&gt;Resident Consumption Where Spend_Type = 'Inventory'&lt;BR /&gt;Group By Material, Plant, Posting_Date, %Key_OpenClose1;&lt;BR /&gt;Unqualify *;&lt;/P&gt;&lt;P&gt;/**************** Opening Stock Logic - Stage2 ****************/&lt;BR /&gt;Concatenate(Consumption)&lt;BR /&gt;Open_Close_Stock:&lt;BR /&gt;Load *,&lt;BR /&gt;(alt((Stock_Open1),0) + alt((Stock_Receipt1),0)-alt((Stock_Issued1),0))as Stock_Close1;&lt;/P&gt;&lt;P&gt;Load Distinct&lt;/P&gt;&lt;P&gt;Temp_OpenClose.Stock_Receipt2 as Stock_Receipt1,&lt;BR /&gt;Temp_OpenClose.%Key_OpenClose1 as %Key_OpenClose1,&lt;BR /&gt;Temp_OpenClose.Stock_Issued2 as Stock_Issued1,&lt;BR /&gt;Temp_OpenClose.Plant as Plant,&lt;BR /&gt;Temp_OpenClose.Material as Material,&lt;BR /&gt;Temp_OpenClose.Posting_Date as Posting_Date,&lt;BR /&gt;If(Temp_OpenClose.Stock_Open,Temp_OpenClose.Stock_Open,Peek(Stock_Close1)) as Stock_Open1&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Resident Temp_OpenClose&lt;BR /&gt;Order By Temp_OpenClose.Material, Temp_OpenClose.Plant, Temp_OpenClose.Posting_Date;&lt;BR /&gt;Drop Table Temp_OpenClose;&lt;BR /&gt;exit Script;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the&amp;nbsp;Temp_Open table I am getting Stock_Open value for 1/1/2018. I need to build a logic for remaining dates.&lt;/P&gt;&lt;P&gt;I am concatenating it with Consumption table in which I have&amp;nbsp; calculated my Stock Issue and stock Receipt.&lt;/P&gt;&lt;P&gt;In the Temp_OpenClose: table I am generating the first level of Stock_Open and Stock_Cose logic.&lt;/P&gt;&lt;P&gt;I make&amp;nbsp;Alt(Sum("Opening Stock Qty1"),0) as my Stock_Open which is nothing but Stock open value for 1/1/2018 for all materials&lt;/P&gt;&lt;P&gt;my stock_close logic is&amp;nbsp;Sum( "Opening Stock Qty1" + Stock_Receipt - Stock_Issued)&lt;/P&gt;&lt;P&gt;%Key_OpenClose1 is basically my key made using Plant,Material,Date and Inventory tag which i will use further in my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now in my&amp;nbsp;Open_Close_Stock table i build the final logic for stock_open and stock_close&lt;/P&gt;&lt;P&gt;basically if my stock_open value for material A on 1/1/2018 is 10 and receipt value is 10 and issue value is 5&lt;/P&gt;&lt;P&gt;them my stock close is stocke_open+receipt- issue so 10+10-5=15 becomes my stock close for material A on 1/1/2018&lt;/P&gt;&lt;P&gt;now for 1/2/2018 for material A stock_open should be previous day stock_close i.e. 15 and then&amp;nbsp;stock close is stocke_open+receipt- issue so 15+ receipt as on 1/2/2018 - issue as on 1/2/2018.&lt;/P&gt;&lt;P&gt;Using the above code i am able to get the below output&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/45876iC002B81158045A1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;my value of stock_open1 and stock_close1 on 1/1/2018 is correct&lt;/P&gt;&lt;P&gt;even&amp;nbsp;stock_close1&amp;nbsp; is working fine functionally because as on 1/2/2018 it is giving 0+540.08-0=540.08&lt;/P&gt;&lt;P&gt;but i am not able to generate stock_open for remaining dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the long post. Please help.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Dec 2021 22:26:21 GMT</pubDate>
    <dc:creator>Qliksense_User</dc:creator>
    <dc:date>2021-12-07T22:26:21Z</dc:date>
    <item>
      <title>Data Modelling</title>
      <link>https://community.qlik.com/t5/Catalog-and-Lineage/Data-Modelling/m-p/1769440#M538</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;Please find my code as below&lt;/P&gt;&lt;P&gt;Temp_Open:&lt;BR /&gt;LOAD&lt;BR /&gt;if(not WildMatch(Replace(LTrim(Replace(Material, '0',' ')),' ', '0'),'3*','4*'),&lt;BR /&gt;Replace(LTrim(Replace(Material, '0',' ')),' ', '0')) as Material,&lt;BR /&gt;'Inventory' as Spend_Type,&lt;BR /&gt;Plant,&lt;BR /&gt;"Opening Stock Qty",&lt;BR /&gt;Date(Date#("Trans. date", 'YYYYMMDD')) as Posting_Date_Stock&lt;BR /&gt;FROM path&lt;BR /&gt;(qvd) where Plant='N201' and Material='108000000021' ;&lt;/P&gt;&lt;P&gt;Concatenate(Consumption)&lt;BR /&gt;LOAD&lt;BR /&gt;Plant ,&lt;BR /&gt;Spend_Type,&lt;BR /&gt;Material ,&lt;BR /&gt;Posting_Date_Stock as Posting_Date ,&lt;BR /&gt;"Opening Stock Qty" as "Opening Stock Qty1"&lt;BR /&gt;Resident Temp_Open;&lt;BR /&gt;Drop Table Temp_Open;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/**************** Opening Stock Logic - Stage1 ****************/&lt;BR /&gt;qualify *;&lt;BR /&gt;NoConcatenate&lt;BR /&gt;Temp_OpenClose:&lt;BR /&gt;Load&lt;BR /&gt;%Key_OpenClose1 , Material , Plant , Posting_Date,&lt;BR /&gt;Sum( "Opening Stock Qty1" + Stock_Receipt - Stock_Issued) as Stock_Close,&lt;BR /&gt;Alt(Sum("Opening Stock Qty1"),0) as Stock_Open,&lt;BR /&gt;Sum (Stock_Issued) as Stock_Issued2,&lt;BR /&gt;Sum (Stock_Receipt) as Stock_Receipt2&lt;BR /&gt;Resident Consumption Where Spend_Type = 'Inventory'&lt;BR /&gt;Group By Material, Plant, Posting_Date, %Key_OpenClose1;&lt;BR /&gt;Unqualify *;&lt;/P&gt;&lt;P&gt;/**************** Opening Stock Logic - Stage2 ****************/&lt;BR /&gt;Concatenate(Consumption)&lt;BR /&gt;Open_Close_Stock:&lt;BR /&gt;Load *,&lt;BR /&gt;(alt((Stock_Open1),0) + alt((Stock_Receipt1),0)-alt((Stock_Issued1),0))as Stock_Close1;&lt;/P&gt;&lt;P&gt;Load Distinct&lt;/P&gt;&lt;P&gt;Temp_OpenClose.Stock_Receipt2 as Stock_Receipt1,&lt;BR /&gt;Temp_OpenClose.%Key_OpenClose1 as %Key_OpenClose1,&lt;BR /&gt;Temp_OpenClose.Stock_Issued2 as Stock_Issued1,&lt;BR /&gt;Temp_OpenClose.Plant as Plant,&lt;BR /&gt;Temp_OpenClose.Material as Material,&lt;BR /&gt;Temp_OpenClose.Posting_Date as Posting_Date,&lt;BR /&gt;If(Temp_OpenClose.Stock_Open,Temp_OpenClose.Stock_Open,Peek(Stock_Close1)) as Stock_Open1&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Resident Temp_OpenClose&lt;BR /&gt;Order By Temp_OpenClose.Material, Temp_OpenClose.Plant, Temp_OpenClose.Posting_Date;&lt;BR /&gt;Drop Table Temp_OpenClose;&lt;BR /&gt;exit Script;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the&amp;nbsp;Temp_Open table I am getting Stock_Open value for 1/1/2018. I need to build a logic for remaining dates.&lt;/P&gt;&lt;P&gt;I am concatenating it with Consumption table in which I have&amp;nbsp; calculated my Stock Issue and stock Receipt.&lt;/P&gt;&lt;P&gt;In the Temp_OpenClose: table I am generating the first level of Stock_Open and Stock_Cose logic.&lt;/P&gt;&lt;P&gt;I make&amp;nbsp;Alt(Sum("Opening Stock Qty1"),0) as my Stock_Open which is nothing but Stock open value for 1/1/2018 for all materials&lt;/P&gt;&lt;P&gt;my stock_close logic is&amp;nbsp;Sum( "Opening Stock Qty1" + Stock_Receipt - Stock_Issued)&lt;/P&gt;&lt;P&gt;%Key_OpenClose1 is basically my key made using Plant,Material,Date and Inventory tag which i will use further in my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now in my&amp;nbsp;Open_Close_Stock table i build the final logic for stock_open and stock_close&lt;/P&gt;&lt;P&gt;basically if my stock_open value for material A on 1/1/2018 is 10 and receipt value is 10 and issue value is 5&lt;/P&gt;&lt;P&gt;them my stock close is stocke_open+receipt- issue so 10+10-5=15 becomes my stock close for material A on 1/1/2018&lt;/P&gt;&lt;P&gt;now for 1/2/2018 for material A stock_open should be previous day stock_close i.e. 15 and then&amp;nbsp;stock close is stocke_open+receipt- issue so 15+ receipt as on 1/2/2018 - issue as on 1/2/2018.&lt;/P&gt;&lt;P&gt;Using the above code i am able to get the below output&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/45876iC002B81158045A1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;my value of stock_open1 and stock_close1 on 1/1/2018 is correct&lt;/P&gt;&lt;P&gt;even&amp;nbsp;stock_close1&amp;nbsp; is working fine functionally because as on 1/2/2018 it is giving 0+540.08-0=540.08&lt;/P&gt;&lt;P&gt;but i am not able to generate stock_open for remaining dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the long post. Please help.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 22:26:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Catalog-and-Lineage/Data-Modelling/m-p/1769440#M538</guid>
      <dc:creator>Qliksense_User</dc:creator>
      <dc:date>2021-12-07T22:26:21Z</dc:date>
    </item>
  </channel>
</rss>

