Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
aarohipatel
Creator II
Creator II

Help with writing expression

Hello everyone,

I need help with writing the following conditions in QV expression of straight table.

Ratio1=  If ([ABC]=0) Then 0 Else ([feild2]/[ABC])

ABC= count(field1)

Ratio2= If([ABC]=0) Then 0 Else ([XYZ]/[ABC])

ABC= count(field1)

XYZ= sum(field2)

UVW =If(([Count(field)]-[field2])=0) Then 0 Else ([field3]/([Count(field1)]-[field2]))

LMN = If( ([field 1] In List ("A" ; "B")) )Then "10" Else If( ([field1] InList("D" ; "F")) )Then "15"  ElseIf( ([field1]="C") )Then "12"  Else "N/A"

Thanks in Advance

16 Replies
sunny_talwar

Lets do this one at a time. Can you elaborate on your second condition again? Is ABC Avg a text that you want or is it the Avg of rating A, B and C? If it is the average, what are the values for ABC, how are they determined?

aarohipatel
Creator II
Creator II
Author

Hi Sunny,

Condition 2:

Rating is a field whose values are alphabets. In the attached Rating Example.xls, ' RATING'  is the rating of the products.

Examples:

Rating of Tables is  'A', in expression results, I want to see:  'A Avg'

Rating of Chairs is  'B',  in expression results, I want to see: ' B Avg'

Rating of Fans  is  'C' , in  expression results, I want to see:  'C Avg'

Rating of Bulbs  is  'D', in  expression results, I want to see: ' D-ABC Avg'

Rating of Sofa  is  'E' , in  expression results, I want to see:  'E Avg'

Rating of Beds  is  'F', in  expression results, I want to see:  'F-ABC Avg'

Rating of Sofa  is  'G' , in expression results, I want to see: ' G Avg'

Rating of Sheets is null,  in Expression results, I want to see: 'Not Rated'


All the expected results are text. 'A Avg' ; D-ABC Avg', 'Not Rated' are all texts.


Thanks

sunny_talwar

Here is the expression for 2nd condition:

=If(IsNull(RATING), 'Not Rated', If(not Match(RATING, 'D', 'F'), RATING & ' Avg', RATING & '-ABC Avg'))


Capture.PNG

If this is what you want, lets move to the third requirement

sunny_talwar

Your expression for third requirement:

Count(Event)/Count (TOTAL Event)

Capture.PNG

sunny_talwar

4th and final requirement

Capture.PNG

Pay close attention to the data model here. As I added an As-of Table (The As-Of Table)

aarohipatel
Creator II
Creator II
Author

All the answers provided (by Sunny T) for all 4 conditions are correct.Could mark only one answer as correct so mentioning it in this post.

Thanks Sunny for your patience and for  helping me with all 4 conditions.

Thanks

Aarohi

sunny_talwar

No problem at all. I am glad I was able to help.

Just so you know, there are helpful answers -> Qlik Community Tip: Marking Replies as Correct or Helpful

Best,

Sunny