Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
AleCruc94
Contributor III
Contributor III

sum in a table

Hi everyone,

 
 
 
 

I have the following table:

[SECTOR, P&L

crd financing , -1,931,806

financial,  4,136,933]

and I have to obtain a new field where the sector "crd financing" is partially (80%) included in the financial sector. I wrote in the following way in the load script:

if(settore = 'CRD FINANCING',(0.8*profit),0) as financial_component

since it works correctly then,

if(settore='FINANCIAL', (profit +financial_component),0) as NewProfit

but it doesn't work.

can someone help me?

thanks

 

 

7 Replies
sunny_talwar

Since financial_component is 0 for anything except CRG FINANCING... your script if(settore='FINANCIAL', (profit +financial_component),0) as NewProfit is essentially equal to if(settore='FINANCIAL', (profit +0),0) as NewProfit

Stoyan_Terziev
Partner - Creator III
Partner - Creator III

Hello Ale Cruc,

 

Can you post a sample of your code here?

You need to make sure you are using preceding loads. The attribute [financial_component] may not exist yet when you try to use it in a formula.

you can try instead of this:

if(settore='FINANCIAL', (profit +financial_component),0) as NewProfit

 

doing this:

if(settore='FINANCIAL', (profit +if(settore = 'CRD FINANCING',(0.8*profit),0)),0) as NewProfit

 

Let me know if this helps!

 

Kind regards,

S.T.

sunny_talwar

Are you may be looking to do this?

 

If(settore = 'CRD FINANCING', (0.8*profit), 
  If(settore = 'FINANCIAL', profit, 0
  )
) as NewProfit

 

AleCruc94
Contributor III
Contributor III
Author

Actually it is more complicated than this as I do not have to fine the real profit of a single sector but of many others.

I try to explain better so my situations is the follwing:

in table1  I have the field SECTOR which is determined by all possible sector i have and the field DESK . 

in table2 I have the measure Profit.

The two table are related by a common filed which is the Portfolio and as usual each Portfolio has its own sector, in this way I have linked Table1 and Table2. 

 

Capture.PNG

Thanks  

 

sunny_talwar

Where exactly are you trying to do this? In the script or front end?

AleCruc94
Contributor III
Contributor III
Author

it does not matter.. i just want to obtain it

AleCruc94
Contributor III
Contributor III
Author

better in the script so that i can use the result in different objects in presentation.