<?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 Using a calculated value to populate another expression in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Using-a-calculated-value-to-populate-another-expression/m-p/2457494#M98568</link>
    <description>&lt;P&gt;Hi.&amp;nbsp; This is a little strange, but I have a request to build something this way-&lt;/P&gt;
&lt;P&gt;I have an expression that calculates a value (closing balance).&amp;nbsp; The report is kind of like a ‘P&amp;amp;L’ template as the values in the columns are added to some of the preceding values.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Brip51_0-1716986018459.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/167048iB90F910B778886C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Brip51_0-1716986018459.png" alt="Brip51_0-1716986018459.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The Closing Balance is&lt;/P&gt;
&lt;P&gt;Net opening insurance contract balances + Total Changes In The Statement of Profit or Loss &amp;amp; OCI + Total Cash Flows&lt;/P&gt;
&lt;P&gt;At the end of a calendar year the closing balance (17,962,052) needs to be used as the next year’s opening balance.&amp;nbsp; So if you select booking date ‘2024-01-31’ the opening balance is 17,962,052.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Brip51_1-1716986166307.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/167049iAADE8D637886ECFA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Brip51_1-1716986166307.png" alt="Brip51_1-1716986166307.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am doing that by using set analysis to calculate the 2024 opening balance as the closing balance (Net opening insurance contract balances + Total Changes In The Statement of Profit or Loss &amp;amp; OCI + Total Cash Flows) but with the 2023 YTD date ranges.&lt;/P&gt;
&lt;P&gt;That works for 2023 to 2024 booking year.&amp;nbsp; My issue is it does not work for any of the next years.&amp;nbsp; Since I am using the opening balance, which is a calculation –&lt;/P&gt;
&lt;P&gt;(&lt;/P&gt;
&lt;P&gt;(Num(Sum({$&amp;lt;[Cash Booking Date] = , [Booking Date] = ,business_effective_year_month = {"&amp;lt;=$(=Max([To Book Year]-1)&amp;amp;12)"}, [UW Year] ={'&amp;gt;=2021&amp;lt;$(=max([To Book Year]))'}&amp;gt;}[Earned Premium Est Inc])/ (Divider),'#,##0.')&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;Num(Sum({$&amp;lt;[Booking Date] =, [Cash Booking Date] = ,[Cash Booking Date Year] = {'&amp;gt;=2021&amp;lt;$(=max([To Book Year]))'}&amp;gt;}cash_premium)/ (Divider),'#,##0.'))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;(Num(Sum({$&amp;lt;[Cash Booking Date] = , [Booking Date] = ,business_effective_year_month = {"&amp;lt;=$(=Max([To Book Year]-1)&amp;amp;12)"}, [UW Year] ={'&amp;gt;=2021&amp;lt;$(=max([To Book Year]))'}&amp;gt;}[Acquisition Expense Est Inc])/ (Divider),'#,##0.')&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;Num(Sum({$&amp;lt;[Booking Date] =, [Cash Booking Date] = ,[Cash Booking Date Year] ={'&amp;gt;=2021&amp;lt;$(=max([To Book Year]))'}&amp;gt;}cash_acquisition_cost)/ (Divider),'#,##0.'))&lt;/P&gt;
&lt;P&gt;)*-1,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To calculate the prior year closing balance it gives me 19,287,125.&amp;nbsp; That is because the actual calculated opening balance for 2024 is 17,213,966 ,not the 17,962,052 that I am ‘rolling over’ from 2023 closing balance to the 2024 opening balance. I want the 2024 closing balance (20,035,210) to populate the 2025 opening balance.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Brip51_2-1716986387424.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/167051iBB5E7396E117414A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Brip51_2-1716986387424.png" alt="Brip51_2-1716986387424.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I am struggling with is how I can always take the prior year closing balance and use that as the opening balance (as I am using the calculated prior year opening balance, which will always be incorrect- why I need to use the closing balance number instead- in the closing balance calculation).&amp;nbsp; Is there a way to save that number (maybe into a variable)???&lt;/P&gt;
&lt;P&gt;Or a different approach that I am missing?&lt;/P&gt;
&lt;P&gt;Any help on this would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Brian&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2024 12:59:21 GMT</pubDate>
    <dc:creator>Brip51</dc:creator>
    <dc:date>2024-05-29T12:59:21Z</dc:date>
    <item>
      <title>Using a calculated value to populate another expression</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-calculated-value-to-populate-another-expression/m-p/2457494#M98568</link>
      <description>&lt;P&gt;Hi.&amp;nbsp; This is a little strange, but I have a request to build something this way-&lt;/P&gt;
&lt;P&gt;I have an expression that calculates a value (closing balance).&amp;nbsp; The report is kind of like a ‘P&amp;amp;L’ template as the values in the columns are added to some of the preceding values.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Brip51_0-1716986018459.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/167048iB90F910B778886C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Brip51_0-1716986018459.png" alt="Brip51_0-1716986018459.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The Closing Balance is&lt;/P&gt;
&lt;P&gt;Net opening insurance contract balances + Total Changes In The Statement of Profit or Loss &amp;amp; OCI + Total Cash Flows&lt;/P&gt;
&lt;P&gt;At the end of a calendar year the closing balance (17,962,052) needs to be used as the next year’s opening balance.&amp;nbsp; So if you select booking date ‘2024-01-31’ the opening balance is 17,962,052.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Brip51_1-1716986166307.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/167049iAADE8D637886ECFA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Brip51_1-1716986166307.png" alt="Brip51_1-1716986166307.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am doing that by using set analysis to calculate the 2024 opening balance as the closing balance (Net opening insurance contract balances + Total Changes In The Statement of Profit or Loss &amp;amp; OCI + Total Cash Flows) but with the 2023 YTD date ranges.&lt;/P&gt;
&lt;P&gt;That works for 2023 to 2024 booking year.&amp;nbsp; My issue is it does not work for any of the next years.&amp;nbsp; Since I am using the opening balance, which is a calculation –&lt;/P&gt;
&lt;P&gt;(&lt;/P&gt;
&lt;P&gt;(Num(Sum({$&amp;lt;[Cash Booking Date] = , [Booking Date] = ,business_effective_year_month = {"&amp;lt;=$(=Max([To Book Year]-1)&amp;amp;12)"}, [UW Year] ={'&amp;gt;=2021&amp;lt;$(=max([To Book Year]))'}&amp;gt;}[Earned Premium Est Inc])/ (Divider),'#,##0.')&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;Num(Sum({$&amp;lt;[Booking Date] =, [Cash Booking Date] = ,[Cash Booking Date Year] = {'&amp;gt;=2021&amp;lt;$(=max([To Book Year]))'}&amp;gt;}cash_premium)/ (Divider),'#,##0.'))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;(Num(Sum({$&amp;lt;[Cash Booking Date] = , [Booking Date] = ,business_effective_year_month = {"&amp;lt;=$(=Max([To Book Year]-1)&amp;amp;12)"}, [UW Year] ={'&amp;gt;=2021&amp;lt;$(=max([To Book Year]))'}&amp;gt;}[Acquisition Expense Est Inc])/ (Divider),'#,##0.')&lt;/P&gt;
&lt;P&gt;-&lt;/P&gt;
&lt;P&gt;Num(Sum({$&amp;lt;[Booking Date] =, [Cash Booking Date] = ,[Cash Booking Date Year] ={'&amp;gt;=2021&amp;lt;$(=max([To Book Year]))'}&amp;gt;}cash_acquisition_cost)/ (Divider),'#,##0.'))&lt;/P&gt;
&lt;P&gt;)*-1,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To calculate the prior year closing balance it gives me 19,287,125.&amp;nbsp; That is because the actual calculated opening balance for 2024 is 17,213,966 ,not the 17,962,052 that I am ‘rolling over’ from 2023 closing balance to the 2024 opening balance. I want the 2024 closing balance (20,035,210) to populate the 2025 opening balance.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Brip51_2-1716986387424.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/167051iBB5E7396E117414A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Brip51_2-1716986387424.png" alt="Brip51_2-1716986387424.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I am struggling with is how I can always take the prior year closing balance and use that as the opening balance (as I am using the calculated prior year opening balance, which will always be incorrect- why I need to use the closing balance number instead- in the closing balance calculation).&amp;nbsp; Is there a way to save that number (maybe into a variable)???&lt;/P&gt;
&lt;P&gt;Or a different approach that I am missing?&lt;/P&gt;
&lt;P&gt;Any help on this would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Brian&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 12:59:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-calculated-value-to-populate-another-expression/m-p/2457494#M98568</guid>
      <dc:creator>Brip51</dc:creator>
      <dc:date>2024-05-29T12:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using a calculated value to populate another expression</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-calculated-value-to-populate-another-expression/m-p/2458500#M98667</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/32065"&gt;@Brip51&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;You Need to First, calculate the closing balances for each year. &lt;BR /&gt;Create a variable for:&lt;/P&gt;
&lt;P&gt;SET NetOpeningBalance = Sum([Net Opening Balance]);&lt;BR /&gt;SET TotalPLOCIChanges = Sum([Total Changes In The Statement of Profit or Loss &amp;amp; OCI]);&lt;BR /&gt;SET TotalCashFlows = Sum([Total Cash Flows]);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;2- Create Closing Balance for each Year&lt;BR /&gt;SET ClosingBalance2023 = $(NetOpeningBalance) + $(TotalPLOCIChanges) + $(TotalCashFlows);&lt;/P&gt;
&lt;P&gt;3- Carry over the closing balance to the next year's opening balance, create variables that calculate the opening balance for each year as the closing balance of the previous year:&lt;/P&gt;
&lt;P&gt;vOpeningBalance2024 = $(vClosingBalance2023);&lt;/P&gt;
&lt;P&gt;4- Generalize for Multiple Years&lt;/P&gt;
&lt;P&gt;In the data load script, you can use a for loop to dynamically calculate and set the closing balances and the following year's opening balance.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Let vNumYears = 'Number of Years'; // Adjust the total number of years considered for calculation&lt;/P&gt;
&lt;P&gt;vYear = 2021 To $(vNumYears) - 1&lt;BR /&gt;Let NextYear = $(vYear) + 1;&lt;BR /&gt;Let ClosingBalance_$(vYear) = Sum({&amp;lt;Year={$(vYear)}&amp;gt;} NetOpeningBalance) + Sum({&amp;lt;Year={$(vYear)}&amp;gt;} TotalPLOCIChanges) + Sum({&amp;lt;Year={$(vYear)}&amp;gt;} TotalCashFlows);&lt;BR /&gt;Let OpeningBalance_$(NextYear) = $(ClosingBalance_$(vYear));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Set Analysis Expression Example:&lt;BR /&gt;For your visualization, you can add measures that dynamically reference these variables.&lt;/P&gt;
&lt;P&gt;5- Use Variables in Expressions&lt;BR /&gt;For example, to calculate the closing balance in a visualization or table:&lt;/P&gt;
&lt;P&gt;Sum(vNetOpeningBalance) + Sum(vTotalPLOCIChanges) + Sum(TotalCashFlows)&lt;/P&gt;
&lt;P&gt;And for the next year's opening balance field:&lt;/P&gt;
&lt;P&gt;IF(Year = 2024, $(vClosingBalance2023),&lt;BR /&gt;IF(Year = 2025, $(vClosingBalance2024),&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;))&lt;/P&gt;
&lt;P&gt;You will dynamically display the closing balance of the year as the opening balance of the next year using the stored variable.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;*****&lt;STRONG&gt;Hope these steps will help you to resolve your issue.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If the issue is solved please mark the answer with Accept as Solution &amp;amp; like it.******&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jun 2024 10:08:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-calculated-value-to-populate-another-expression/m-p/2458500#M98667</guid>
      <dc:creator>TauseefKhan</dc:creator>
      <dc:date>2024-06-02T10:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using a calculated value to populate another expression</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-calculated-value-to-populate-another-expression/m-p/2463953#M99072</link>
      <description>&lt;P&gt;Hi TauseefKhan,&lt;/P&gt;
&lt;P&gt;Thank you.&amp;nbsp; This sounds like a good approach.&amp;nbsp; I will try this and let you know if I can get it to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Brian&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2024 17:25:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-calculated-value-to-populate-another-expression/m-p/2463953#M99072</guid>
      <dc:creator>Brip51</dc:creator>
      <dc:date>2024-06-19T17:25:50Z</dc:date>
    </item>
  </channel>
</rss>

