Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
gwalsh919
Contributor
Contributor

Help, I suck at scripting in Qlik Sense

Hey, so I'm new to Qlik and attempting to create a column that I just can't get working.

I need to take the average age of "Customers" but only if they are < 100, >= 0, and their name contains the letters "P", "B", or "D'.

I've of course changed some details for confidentiality, but the methodology is the same. I've also tried to use if statements and set analysis to achieve this, but was successful with neither.

So far my code is as follows, but I don't know how to combine the two expressions into one:

#Outputs the avg of all Age values that are between [0,100)

avg(if(Age<100 and Age>=0, Age))

#Outputs all Name values that contain P, B, or D

{<Name={"P*", "B*", "D*"}>} Name

If anyone knows how to combine these two expressions into one column, help would be greatly appreciated.

Thank you

Labels (3)
1 Solution

Accepted Solutions
joseph_morales
Creator II
Creator II

Hello @gwalsh919

Something like that:

avg({<Age={">=0<100"},Name={"P*","D*","B*"}>}Age)

Regards

Best Regards,
Joseph Morales

View solution in original post

2 Replies
joseph_morales
Creator II
Creator II

Hello @gwalsh919

Something like that:

avg({<Age={">=0<100"},Name={"P*","D*","B*"}>}Age)

Regards

Best Regards,
Joseph Morales
gwalsh919
Contributor
Contributor
Author

Worked perfectly and solved my issue, thank you so much!