<?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: Pivot table where each row has different calculation logic. in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2550026#M110342</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/172757"&gt;@priscilarubim&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is typical P&amp;amp;L layout based on simple grouping of accounts and few extra tweaks you would have to use to put % lines. To answer your question we would need to know what your data source is and how you model your data. I prefer to think how I want to work with my data model before trying to write any expression so I would make sure signs for amounts are already taken care of and we have proper debits/credits amounts in journals.&lt;/P&gt;&lt;P&gt;The usual source of data for the above scenario (except %) is GL amount aggregated by accounts. Then all you need is just grouping of those accounts with corresponding label you want to use to display a measure and in reality you dont even need to do any gymnastics as values in GL should already have correct debit/credit signs hence your measure should only be Sum(GL_Amount) + set analysis for CY and LY periods typically based on reference calendar.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the % measures you need additional identifier as for those you may need to create IF() statement and use different number format. Properly built reference calendar will handle CY and LY scenario and budget obviously just concatenated to fact table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a stock - standard example we were using for many years and many clients and it works a treat and is super simple. Attaching sample app with the principles and example based on Ctrl+0+0 data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 May 2026 14:41:29 GMT</pubDate>
    <dc:creator>Lech_Miszkiewicz</dc:creator>
    <dc:date>2026-05-27T14:41:29Z</dc:date>
    <item>
      <title>Pivot table where each row has different calculation logic.</title>
      <link>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2549945#M110335</link>
      <description>&lt;P class=""&gt;Hi Community,&lt;/P&gt;&lt;P class=""&gt;What is the best approach to build a P&amp;amp;L report as a pivot table in Qlik Cloud (columns: Actual / Budget / Prior Year) when each row follows a completely different calculation rule, without ending up with a single enormous measure expression?&lt;/P&gt;&lt;DIV class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="priscilarubim_0-1779818561552.png" style="width: 869px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/188542i03DD54BDFB28C4EC/image-dimensions/869x463?v=v2" width="869" height="463" role="button" title="priscilarubim_0-1779818561552.png" alt="priscilarubim_0-1779818561552.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P class=""&gt;In Crystal, each row was hardcoded with its own formula. In Qlik, I need to find a scalable way to handle this, ideally driven by a metadata/mapping table that defines each line's account range, formula type, and sign.&lt;/P&gt;&lt;P class=""&gt;Has anyone tackled this pattern before?&lt;/P&gt;&lt;P class=""&gt;Any examples or approaches are welcome. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2026 18:04:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2549945#M110335</guid>
      <dc:creator>priscilarubim</dc:creator>
      <dc:date>2026-05-26T18:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table where each row has different calculation logic.</title>
      <link>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2549970#M110337</link>
      <description>&lt;P&gt;I think i have i solution to this usecasd here:&amp;nbsp;&lt;A href="https://arntsen.se/projekt/rapport" target="_blank" rel="noopener"&gt;https://arntsen.se/projekt/rapport&lt;/A&gt;. Github source: &lt;A href="https://github.com/veglar/qliksense-sublib/blob/main/data_load_script/sublib.rapport.qvs" target="_blank"&gt;https://github.com/veglar/qliksense-sublib/blob/main/data_load_script/sublib.rapport.qvs&lt;/A&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Account intervals. Even overlapping like `4000..4099` on one row and `4000..4999` on another.&lt;/LI&gt;&lt;LI&gt;Reference other rows in your in your configuration both adding and division (i don't remember if it handles subtraction,&amp;nbsp; I think I solved that by defining multiple intervals that excluded what I did not want to include)&lt;/LI&gt;&lt;LI&gt;It also handle parallel account plans. Let's say you want to combine the pnl for two companies ("Bolag") when they have a different account setup.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Back when i wrote this I was focusing on a Swedish audience, so the code and comments are in Swedish. I have not looked at it in a while, but if it is found useful then it might find some time to revamp a bit on it and at least change it into English.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2026 05:19:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2549970#M110337</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2026-05-27T05:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table where each row has different calculation logic.</title>
      <link>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2550020#M110339</link>
      <description>&lt;P&gt;I'll take a look, maybe I can get help from some AI to translate. Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2026 13:44:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2550020#M110339</guid>
      <dc:creator>priscilarubim</dc:creator>
      <dc:date>2026-05-27T13:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table where each row has different calculation logic.</title>
      <link>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2550024#M110340</link>
      <description>&lt;P&gt;I don't know if it's best-practice, but I use an external file for this with "generic" formulas.&lt;/P&gt;&lt;P&gt;It'll typically look something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Or_0-1779890965280.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/188552i79A7FCB3D9B5965F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Or_0-1779890965280.png" alt="Or_0-1779890965280.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formulas tend to run something like this (Note that this is QV, but the same logic applies in QS):&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if(only(PNL_ISPERCENT)=1,num(if(sum({&amp;lt; [Period Name]=&amp;gt;} if(Type = 'F',1))&amp;gt;0,1)*&lt;BR /&gt;PNL_SIGN*(SUM({&amp;lt;[Period Name]= &amp;gt;}$(Amount_Forecast))&lt;BR /&gt;+&lt;BR /&gt;sum({&amp;lt;Category=p(Category) ,[Period Name] =,[Period Year] = {$(=SELECT_YEAR)} &amp;gt;} if([Expenses Category Number] &amp;gt; 20,$(Amount_var),0)))&lt;BR /&gt;/&lt;BR /&gt;sum({&amp;lt;[Expenses Category Number] = {10}, [Period Name]= &amp;gt;}total $(Amount_Forecast))&lt;BR /&gt;,'#,##0.0%'),num(SUM({&amp;lt;[Period Name]= &amp;gt;}$(Amount_Forecast))&lt;BR /&gt;+&lt;BR /&gt;sum({&amp;lt;Category=p(Category) ,[Period Name] =,[Period Year] = {$(=SELECT_YEAR)} &amp;gt;}&lt;BR /&gt;if([Expenses Category Number] &amp;gt; 20,$(Amount_var),0)),if(PNL_REVERSE=1,'-#,##0;#,##0;-','#,##0;-#,##0;-')))&lt;/P&gt;&lt;P&gt;With the formatting applied in the relevant settings for styling (background, bold, etc).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Or_1-1779891456470.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/188553i69A18738B45AF938/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Or_1-1779891456470.png" alt="Or_1-1779891456470.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This can be simplified in many cases e.g. the set analysis will probably be mostly unnecessary for most use cases, this app has a always-one-selected rule on period and deals with budget forecast as well as the actual PNL. It has the added advantage that you can pivot and each section contains the underlying rows used to calculate it (which means rows are duplicated, of course, but that's intentional).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2026 14:18:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2550024#M110340</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2026-05-27T14:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table where each row has different calculation logic.</title>
      <link>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2550026#M110342</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/172757"&gt;@priscilarubim&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is typical P&amp;amp;L layout based on simple grouping of accounts and few extra tweaks you would have to use to put % lines. To answer your question we would need to know what your data source is and how you model your data. I prefer to think how I want to work with my data model before trying to write any expression so I would make sure signs for amounts are already taken care of and we have proper debits/credits amounts in journals.&lt;/P&gt;&lt;P&gt;The usual source of data for the above scenario (except %) is GL amount aggregated by accounts. Then all you need is just grouping of those accounts with corresponding label you want to use to display a measure and in reality you dont even need to do any gymnastics as values in GL should already have correct debit/credit signs hence your measure should only be Sum(GL_Amount) + set analysis for CY and LY periods typically based on reference calendar.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the % measures you need additional identifier as for those you may need to create IF() statement and use different number format. Properly built reference calendar will handle CY and LY scenario and budget obviously just concatenated to fact table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a stock - standard example we were using for many years and many clients and it works a treat and is super simple. Attaching sample app with the principles and example based on Ctrl+0+0 data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2026 14:41:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2550026#M110342</guid>
      <dc:creator>Lech_Miszkiewicz</dc:creator>
      <dc:date>2026-05-27T14:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table where each row has different calculation logic.</title>
      <link>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2550053#M110343</link>
      <description>&lt;P&gt;Unfortunately, I can't show more than I've already mentioned because it's sensitive data, but what was done was basically what you described. Thank you for responding. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2026 17:28:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Pivot-table-where-each-row-has-different-calculation-logic/m-p/2550053#M110343</guid>
      <dc:creator>priscilarubim</dc:creator>
      <dc:date>2026-05-27T17:28:42Z</dc:date>
    </item>
  </channel>
</rss>

