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: 
kvr9
Creator
Creator

Subtraction of two SET Variables

Hello,

I'm stuck with an issue with subtraction. My data contain two variables was trying to subtract them but it is not working properly

Set vCountry=1,

Set vValue =if(vCountry =1,Localcurrency, Localcurrency*exchangerate)

Set vSale =if(vCountry=1,Sales,Sales*exchangerate)

above is the variables I have created for my data and was trying to subtract them as below.

vValue -vSale

I am getting result for local values but not the converted values i.e if country is 0 or more than 1 then it should convert using exchange rates but it is not working as expected

Can some one help me out.

Thanks.

23 Replies
Anil_Babu_Samineni

In that 3rd image, Should select USD only. can you show the data points using USD selection. You need to get 1.7 $. Aren't you?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
kvr9
Creator
Creator
Author

The 3rd Image is shows correct calculation ,we need calculation based on conversion I.e USD and EUR.

EUR calculation is perfect,coming to my 2nd Image $26.8 -$0.2 is $26.6 but I'm getting $24.9.Which is wrong upon my analysis found the calculation is not reflecting for conversion (USD).

sasiparupudi1
Master III
Master III

Please try

=Num

(

(SUM({<Year={$(=max(Year))},[Payment Type]={'R&D'}>}if($(vLocalValue)=1,(DisclosedToV*ExchangeRateToUSD), DisclosedToV)/UnitDivision))

-

(sum({<Year={$(=max(Year))},[Payment Type]={'R&D'}>} if($(vLocalValue) =1, SpendAmount, (SpendAmount/ExchangeRateToUSD))/UnitDivision),'$(vNumberFormat)')

)

kvr9
Creator
Creator
Author

Hi Sasidhar,

The above expression works fine ,but I would like to replace it with variables.

Set vValueField = =if(vLocalValue=1, '[SpendAmount]', '[SpendAmount]/[ExchangeRateToUSD]');

Set vDisclosedToV = =if(vLocalValue=1,'[DisclosedToV]*[ExchangeRateToUSD]', '[DisclosedToV]');