Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

If in Script

This is my script,

load%_BNO,

if(UNIT.GRADEFIX = '' , '', num(avg(UNIT.M_MILEAGE / 1000) + Avg(UNIT.AGEMONTHS) + Avg(UNIT.GRADEFIX*10) +  Avg(UNIT.CAPCLEAN_ORIG /1000))) as Buyer.GCT_Score

  

FROM

[$(QVD_Path)\BUYER_unit.qvd]

(qvd)

group by %_BNO;

It's again saying invalid expression?

Thanks

Gareth

Labels (1)
4 Replies
alexandros17
Partner - Champion III
Partner - Champion III

You need an aggregation function for

if(UNIT.GRADEFIX = '' , '', num(avg(UNIT.M_MILEAGE / 1000) + Avg(UNIT.AGEMONTHS) + Avg(UNIT.GRADEFIX*10) +  Avg(UNIT.CAPCLEAN_ORIG /1000))) as Buyer.GCT_Score

something like

Avg(

if(UNIT.GRADEFIX = '' , '', num(avg(UNIT.M_MILEAGE / 1000) + Avg(UNIT.AGEMONTHS) + Avg(UNIT.GRADEFIX*10) +  Avg(UNIT.CAPCLEAN_ORIG /1000))) as Buyer.GCT_Score

)

... even if this expression (the one I've written) doesn't work

sunny_talwar
MVP
MVP

Try this:

Load%_BNO,

if(UNIT.GRADEFIX = '' , '', num(avg(UNIT.M_MILEAGE / 1000) + Avg(UNIT.AGEMONTHS) + Avg(UNIT.GRADEFIX*10) +  Avg(UNIT.CAPCLEAN_ORIG /1000))) as Buyer.GCT_Score

FROM

[$(QVD_Path)\BUYER_unit.qvd]

(qvd)

Group By %_BNO, UNIT.GRADEFIX;

Anonymous
Not applicable
Author

Thanks sunindia,

What I'm trying to do is if the avg(Unit.Gradefix = '' then make it a 2 otherwise use avg(unit.gradefix)

My expression is below however I don't think it's correct.

Load%_BNO,

if(Avg(UNIT.GRADEFIX = '' , 2 + num(avg(UNIT.M_MILEAGE / 1000) + Avg(UNIT.AGEMONTHS) + Avg(UNIT.GRADEFIX*10) +  Avg(UNIT.CAPCLEAN_ORIG /1000))

,

num(avg(UNIT.M_MILEAGE / 1000) + Avg(UNIT.AGEMONTHS) + Avg(UNIT.GRADEFIX*10) +  Avg(UNIT.CAPCLEAN_ORIG /1000))) as Buyer.GCT_Score

FROM

[$(QVD_Path)\BUYER_unit.qvd]

(qvd)

Group By %_BNO, UNIT.GRADEFIX;

sunny_talwar
MVP
MVP

Not sure I understand, do you have a sample we can look at?