Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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

1 Solution

Accepted Solutions
swuehl
MVP
MVP

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
swuehl
MVP
MVP

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)

tresesco
MVP
MVP

Put the expression simply like: = FieldNameWithTargetData        

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

Not applicable
Author

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

Not applicable
Author

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! )