Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

nested if() value

Hey guys,

I'm struggling with an easy problem (I think it's easy anyway).

I've got a dimension called "group" with values "set1", "set2", "set3", ....

Each value has got it's own target (sales):

set1 = 10.000 euro

set2 = 20.000 euro

set3 = 30.000 euro

I've got a chart (table) that shows the current sales for each set. In the second column (second expression), it should show me the target for each set.

(I know I can add a new field, but I do not want to touch the codes).

So I was thinking something like:

=if (group = {'set1'}, 10000, if (group = {'set2'}, 20000, .... })

See where I am going? Like a nested if-function in Excel..

Does anyone know how to enter the expression?

Thanks a lot!

Zipke

Tags (2)
1 Solution

Accepted Solutions
Highlighted
MVP
MVP

Re: nested if() value

If I understand correctly, your idea should work:

=if (group = 'set1', 10000, if (group = 'set2', 20000, .... ))

or maybe like

=pick(match(group,'set1','set2'),

10000,

20000

)

edit:

Or just create a INLINE table in your script and use the associative logic:

LOAD * INLINE [

group, target

set1, 10000

set2, 20000

];

Then just use an expression

=only(target)

View solution in original post

4 Replies
Highlighted
MVP
MVP

Re: nested if() value

If I understand correctly, your idea should work:

=if (group = 'set1', 10000, if (group = 'set2', 20000, .... ))

or maybe like

=pick(match(group,'set1','set2'),

10000,

20000

)

edit:

Or just create a INLINE table in your script and use the associative logic:

LOAD * INLINE [

group, target

set1, 10000

set2, 20000

];

Then just use an expression

=only(target)

View solution in original post

Highlighted
MVP
MVP

Re: nested if() value

Put the expression simply like: = FieldNameWithTargetData        

Or, if you want the numeric representation may try:    =Num(Subfield(TragetField, '.', 1))*1000    

Highlighted
Not applicable

Re: nested if() value

Ha alright, the first part of you reply actually worked. It didn't work when I did it because of the {  } I used..

Thanks, I think I've got it already!

Will also try the other options! May be useful at some point in life

Highlighted
Not applicable

Re: nested if() value

Hey tresesco, thank you for your reply.

Can you please explain me the first part of your reply? What does this actually do?

(The second part won't be useful, I just used those number 1> 10000, 2> 20000, ...,  to make the communication easier, but they are not the correct numbers. But it would have been a clever solution tough! Thanks! )