Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
azimabadi
Creator III
Creator III

Expression with operator from table

Hi all,

my data model is something like this :

Name        O        V2

----------+------+--------------

Jack     |    *   |     2

John     |    /   |     4

Name       V1

----------+--------

Jack     |  100

Jack     |  200

John     |    50

John     |  230

i need an expression that calculate the value of ( sum(V1) O V2 ) for each row. This means that i need :

Jack : 300 * 2 = 600

John : 280 / 4 = 70

i tested sum(v1) $(O) $(V2) , but it dosen't work.

i will appreciate any idea.

Best regards

Peyman

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Here's one approach.

=pick(

match(O, '*', '/')

,sum(V1) * V2

,sum(V1) / V2

)

I'm not sure how many operators you have. But if you have just * and /, another approach would be:

=sum(V1) * if(O='/', 1/V2, V2)

-Rob

http://robwunderlich.com

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Here's one approach.

=pick(

match(O, '*', '/')

,sum(V1) * V2

,sum(V1) / V2

)

I'm not sure how many operators you have. But if you have just * and /, another approach would be:

=sum(V1) * if(O='/', 1/V2, V2)

-Rob

http://robwunderlich.com

azimabadi
Creator III
Creator III
Author

Thank you Rob for answer. It solved my problem.