Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
stephenedberkg
Creator II
Creator II

Subtract same fields data

I have the Transaction type it contain Credit,invoice ,FIS and FIR

i want to subtract Invoice-Credit that is my sales.

i wrote like this

=sum({<Year={$(=Max(Year))},MonthID={$(=Max(MonthID))},TransactionType={'INVOICE'}>}#InvNetSales) -

sum({<Year={$(=Max(Year))},MonthID={$(=Max(MonthID))},TransactionType={'CreditNote'}>}#InvNetSales)

i Got the sales values but i want some easy way to implement this formula.

thanks in advance

1 Solution

Accepted Solutions
gautik92
Specialist III
Specialist III

create individual variables for both invoice and credit then you can use it in your expression

View solution in original post

9 Replies
gautik92
Specialist III
Specialist III

create individual variables for both invoice and credit then you can use it in your expression

stephenedberkg
Creator II
Creator II
Author

Yeah that is also one way.

=Sum({<Year={$(=Max(Year))},MonthID={$(=Max(MonthID))},TransactionType={'CreditNote'}- {'INVOICE'}>}#InvNetSales)

Is it write way to write the formula like above?

sunny_talwar

I don't think this will work. I think what you have initially is the only front end method to do it.

gautik92
Specialist III
Specialist III

Dear Stephen Edberkg ,

It wont work I hope

stephenedberkg
Creator II
Creator II
Author

need some alternative way

stephenedberkg
Creator II
Creator II
Author

Do you have any other methods

sijojoseph22
Creator II
Creator II

As a first step you can use vairable for '$(=Max(Year))}'  and $(=Max(MonthID))}  which will simply your formula little further.

Second step you can create field  '#InvNetSales' for 'INVOICE' and 'CREDIT' seperatly in the script and you can apply this field directly the the fomula. This will help to remove the 'TransactionType' from the Set Analysis.

gautik92
Specialist III
Specialist III

in the Script itself create two fields for sum of Invoice and credit then use it in the formula but creating variables is quite easy

sasiparupudi1
Master III
Master III

may be you can use a parameterised variable here.Please check out the following post

https://community.qlik.com/docs/DOC-9045

hth

Sasi