Announcements
cancel
Showing results for
Did you mean:
Contributor III

## Calculation

Hi

I need an urgent help on how to compute the following:

NewColumn = (Today's data - Ytd's data ) / Ytd's data

It is a financial data, I would like to derive the above column based on trade date and amount field..

Sample data:

12-Dec-2019, A, 500

13-Dec-2019, A, 300

For 13 Dec 2019, the new column value will be (300 - 500)/500

=> Condition on FundCode for calculation as well.

May I know how I can implement this on QS?

Labels (3)

• ### Qlik Sense

1 Solution

Accepted Solutions
Partner - Creator

Hi @gnmq ,

"12-Dec-2019, A, 500
13-Dec-2019, A, 300
For 13 Dec 2019, the new column value will be (300 - 500)/500"

Above can be achieved in backend by creating a new field as below:
FundCode,
Amount,
if(FundCode = Previous(FundCode),
(Amount - Previous(Amount))/Previous(Amount),  Amount)       as     NewColumn
From XYZ<File Path  & Name>

Let me know if it works.

Regards,
AK

4 Replies
Partner - Creator

Hi @gnmq ,

It would be easier to help if you provide some more context to your requirements/Issue.

Regards,
AK

Contributor III
Author

Hi AK,

I have updated my question. Thanks for the reply

Partner - Creator

Hi @gnmq ,

"12-Dec-2019, A, 500
13-Dec-2019, A, 300
For 13 Dec 2019, the new column value will be (300 - 500)/500"

Above can be achieved in backend by creating a new field as below:
FundCode,
Amount,
if(FundCode = Previous(FundCode),
(Amount - Previous(Amount))/Previous(Amount),  Amount)       as     NewColumn
From XYZ<File Path  & Name>

Let me know if it works.

Regards,
AK

Contributor III
Author

Hi AK,

This works for me. Thanks so much for your help!

Tags