Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
n1ef5ng1
Creator
Creator

Why can't I use IF statement on Expression

=if(Activity_Code = 'LOADER',
(
Sum({<Service_Type_Indicator = {FOM()'},OPS_Direction = {'EWF'}>}TEU) + (sum({<Service_Type_Indicator={FOM()'},OPS_Direction = {'EWF'}>}Transit_TEU) * 2))
/
(
sum({<Service_Type_Indicator = {FOM()'},OPS_Direction = {'EWF'}>}Capacity) * 2)
* 100)

Hi does anybody know what is the problem with this code? My expression of the sum(TEU) is correct but however when i use if statement, it does not show.

For my other report, I can use if statement before fulfilling the sum expression.

I believe is a bug for this qlikview program somehow. Thanks anyone who can solve this problem

11 Replies
MayilVahanan

Hi

I think, you missed open quotes before FOM()?

=if(Activity_Code = 'LOADER',
(
Sum({<Service_Type_Indicator = {'FOM()'},OPS_Direction = {'EWF'}>}TEU) + (sum({<Service_Type_Indicator={'FOM()'},OPS_Direction= {'EWF'}>}Transit_TEU) * 2))
/
(
sum({<Service_Type_Indicator = {'FOM()'},OPS_Direction = {'EWF'}>}Capacity) * 2)
* 100)


And check

(sum({<Service_Type_Indicator = {'FOM()'},OPS_Direction = {'EWF'}>}Capacity) * 2) not an zero values?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
n1ef5ng1
Creator
Creator
Author

this is my code. it does contain values. afterwhich i added a if statement as i need to eliminate certain records

 

=

if(Activity_Code = 'LOAD',
(
Sum({<Service_Type_Indicator = {'EFE(MED)'},OPS_Direction = {'E'}>}TEU) + (sum({<Service_Type_Indicator={'EFE(MED)'},OPS_Direction = {'E'}>}Transit_TEU) * 2))
/
(
sum({<Service_Type_Indicator = {'EFE(MED)'},OPS_Direction = {'E'}>}Capacity) * 2)
* 100)

MayilVahanan

HI

Can you provide a sample file?

Activity_Code contains "LOAD" or  "Load", is there relation between Activity_Code and Dimension?

It helps for us.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
CELAMBARASAN
Partner - Champion
Partner - Champion

What are the dimesions you have used?

Based on your expression Activity_Code should be specified in dimension.

If possible can you post sample app.

abeyphilip
Creator II
Creator II

Hi Benn,

Not sure if this is the problem, added one extra bracket before multiplying with 100.

if(Activity_Code = 'LOAD',

((Sum({<Service_Type_Indicator = {'EFE(MED)'},OPS_Direction = {'E'}>}TEU) + (sum({<Service_Type_Indicator={'EFE(MED)'},OPS_Direction = {'E'}>}Transit_TEU) * 2))

/

(sum({<Service_Type_Indicator = {'EFE(MED)'},OPS_Direction = {'E'}>}Capacity) * 2))

* 100)

Rgds,

Abey

matthieu_burel
Luminary Alumni
Luminary Alumni

You formula can working depending how you use it.

Is it in the script ? a text-object ? a graph ?

n1ef5ng1
Creator
Creator
Author

My dimensions is just month year. I diden use activity code on my dimension.

Sent from my HTC

CELAMBARASAN
Partner - Champion
Partner - Champion

Then you should use aggr around that

=

Aggr(if(Activity_Code = 'LOAD',
(
Sum({<Service_Type_Indicator = {'EFE(MED)'},OPS_Direction = {'E'}>}TEU) + (sum({<Service_Type_Indicator={'EFE(MED)'},OPS_Direction = {'E'}>}Transit_TEU) * 2))
/
(
sum({<Service_Type_Indicator = {'EFE(MED)'},OPS_Direction = {'E'}>}Capacity) * 2)
* 100),Activity_Code)

n1ef5ng1
Creator
Creator
Author

this works but does this works the same as my previous code, as in the logic behind it.

Not well versed on aggr at the moment