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: 
marson_esqogito
Partner - Contributor II
Partner - Contributor II

replacement field to operation

Hi,

i have a similar table

and i would like to have a similar result without using "if" expression (see the 4° column) like the 5° column (that obviously don't work)

some suggestions?

many thanks

Mauro

1 Solution

Accepted Solutions
morganaaron
Specialist
Specialist

Or you can use

Pick(Match(F2, '/', '*'), F1/F3, F1*F3)

in the expression, which would replicate what you're trying to do!

View solution in original post

6 Replies
morganaaron
Specialist
Specialist

If you can add it into your load:

Load Evaluate(F1 & F2 & F3) as Result,
*
Inline [
F1, F2, F3
10, /, 5
20, *, 5
]
;

Would give you what you want.

marson_esqogito
Partner - Contributor II
Partner - Contributor II
Author

Thanks,

but there is no possibility to make this evaluation on expression?

my example is simple, but in the production file the situation is more complex.

NickHoff
Specialist
Specialist

You could with an IF statement, but it may slow down your load.

IF(F2 = '/',F1/F3,

IF(F2 = '*', F1/F3))

Another option is to use the PICK function after you create an INLINE table with the ID of the operation you'd like to perform.

PICK(%PICKID, F1/F3,

F1*F3))

marson_esqogito
Partner - Contributor II
Partner - Contributor II
Author

like i said in the first question,

"If" statement is not usable , the update of the table object is too slow and use so much RAM.

NickHoff
Specialist
Specialist

It's not possible without using an IF statement or a PICK statement.  However, PICK will take a lot less ram up than the IF.

Create the Inline like:

PICKOp:

LOAD * INLINE [

    %OpID, %Operation

    1, F1 / F3

    2, F1 * F3

];

Then

PICK(%OpID,

SUM(F1)/SUM(F3),

SUM(F1)*SUM(F3))

If you don't want to SUM, just do F1/F3, F1*F3

morganaaron
Specialist
Specialist

Or you can use

Pick(Match(F2, '/', '*'), F1/F3, F1*F3)

in the expression, which would replicate what you're trying to do!