
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to use variable in IF statement
Hi,
I have a variable in qlikview where I am calculating top 1 country.
Now I am using this variable to display the sales of each state for the country from the variable.
So if the variable name is vCountry.
I am using this statement in Dimension of Pie Chat:
If(country = $(vCountry), State)
But thsi is not working.
I need help in resolving this.
Please help me here.
Thanks
- « Previous Replies
-
- 1
- 2
- Next Replies »
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Avinash,
Thanks for your help.
I realized that I was doing wrong thing. My expression in variable was not working fine. I do not know why. Because when I use that variable in List Box, I was getting one value. But when I used that variable in Text Box, It was not showing any result.
Now I am using the below expression in my variable:
only(if(aggr(Rank(Sum([Sales Amt])),Country)=1,Country))
and I am getting country name in Text Box and List Box both. (THIS IS FOR TESTING THAT MY VARIABLE IS WORKING FINE)
Now I am using this variable as Sunny has suggested and am getting the result.
I am very thankful to all for your valuable time and suggestion.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What about this:
If(country = vCountry, State)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If(country = $(vCountry), State)
Should work. Check value of your variable. Can you share your qvw file..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sunny,
Thanks for your help.
But it is not working.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How is vCountry gets its value?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
change it into
If(country = '$(vCountry)', State)
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hope 'country' spelled correctly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sunny, Yes, the variable vCountry is getting value from Country field only. It is dynamic value based on the other filter selection.
Now I want to compare this variable value with the Country Field and get the sum of sales for this country value.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Martin, when I am using this, I can see that qlikview is replacing '$(vCountry)' with the formula I have written in variable.
Ideally it should calculate the formula and then replace '$(vCountry)' with the result of formula. But this is not happening.
This is the rootcause why this is not working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So if you are already making selection in Country field, I would expect this chart to drill down to only show states for the countries you have selected. Why do you need an if statement here?

- « Previous Replies
-
- 1
- 2
- Next Replies »