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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
agni_gold
Specialist III
Specialist III

Error: Error in expression: Sum takes 1 parameter

Hi Friends ,

I am writing below expression

(If(Dimensionality()=1 or Dimensionality()=0,

sum({StateB<_GHQFlg=,ACTUALITY_KEY={'AC'},VARIANCE_BASE_SK={'BU'}, Year=$::Year,Month=$::Month>}$(vMetricBU_B_RM)),

sum({StateB<_GHQFlg=$::_GHQFlg,ACTUALITY_KEY={'AC'},VARIANCE_BASE_SK={'BU'}, Year=$::Year,Month=$::Month>}$(vMetricBU_B_RM))))

and variable has below expression

vMetricBU_B_RM:

=(If(Only({StateB}[KPI 22])='Total Volumes1','VOL___ORGANIC_GROWTH_RM','FIN___ORGANIC_GROWTH_RM'))

I am getting below error ,

Error: Error in expression: Sum takes 1 parameter

Please help to correct this.

Thanks

16 Replies
sunny_talwar

I think since you are using Only() function in your variable, you are basically using an aggregation within an aggregation. This might only work with a use of Aggr() function. Do you have a sample you can share with the expected output to help you better?

agni_gold
Specialist III
Specialist III
Author

Sorry sunny , application is at client location but i have also tried with

=(If(MAx({StateB}[KPI 22])='Total Volumes1','VOL___ORGANIC_GROWTH_RM','FIN___ORGANIC_GROWTH_RM'))


but still is was showing same error ,


sunny_talwar

Max, Min, Sum, Avg, Only are all Aggregation functions and you cannot do

Sum(If(Max(.....)) or Sum(If(Only(...))

You need to do this

Sum(Aggr(If(Max(....)))

Does this make sense?

agni_gold
Specialist III
Specialist III
Author

I have tried like this

=sum(If(Aggr(Max({StateB}[KPI 22]),[KPI 22])='Total Volumes1','VOL___ORGANIC_GROWTH_RM','FIN___ORGANIC_GROWTH_RM'))

it is giving 0

Digvijay_Singh

May be try this without variable -

=If(Dimensionality()=1 or Dimensionality()=0,

sum({StateB<_GHQFlg=,ACTUALITY_KEY={'AC'},VARIANCE_BASE_SK={'BU'}, Year=$::Year,Month=$::Month,[KPI 22]={'Total Volumes1'}>}VOL___ORGANIC_GROWTH_RM),

sum({StateB<_GHQFlg=$::_GHQFlg,ACTUALITY_KEY={'AC'},VARIANCE_BASE_SK={'BU'}, Year=$::Year,Month=$::Month,[KPI 22]={"[KPI 22]<>'Total Volumes1'"}>}FIN___ORGANIC_GROWTH_RM))

Anil_Babu_Samineni

Set analysis syntax should be sum({<>} sales)

But, in your expression

(If(Dimensionality()=1 or Dimensionality()=0,

sum({StateB<_GHQFlg=,ACTUALITY_KEY={'AC'},VARIANCE_BASE_SK={'BU'}, Year=$::Year,Month=$::Month>}$(vMetricBU_B_RM)),

sum({StateB<_GHQFlg=$::_GHQFlg,ACTUALITY_KEY={'AC'},VARIANCE_BASE_SK={'BU'}, Year=$::Year,Month=$::Month>}$(vMetricBU_B_RM))))

Can I know the reason why stateb indicates as current or all selections

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
agni_gold
Specialist III
Specialist III
Author

Thanks ,

But in your first part

=If(Dimensionality()=1 or Dimensionality()=0,

sum({StateB<_GHQFlg=,ACTUALITY_KEY={'AC'},VARIANCE_BASE_SK={'BU'}, Year=$::Year,Month=$::Month,[KPI 22]={'Total Volumes1'}>}VOL___ORGANIC_GROWTH_RM),

sum({StateB<_GHQFlg=$::_GHQFlg,ACTUALITY_KEY={'AC'},VARIANCE_BASE_SK={'BU'}, Year=$::Year,Month=$::Month,[KPI 22]={"[KPI 22]<>'Total Volumes1'"}>}FIN___ORGANIC_GROWTH_RM))


You have retten only for VOL , but i need to change here also based on condition if KPI 22 is not total volumes1 then i need to used FIN___ORGANIC_GROWTH_RM

agni_gold
Specialist III
Specialist III
Author

Thanks,

Yes it is written correctly i think , but expression pointing to StateB , that's why we have written like this , please provide any easy solution if you have

Digvijay_Singh

I agree with Sunny but the error message indicates that the variable expansion somehow creating two parameters to SUM function. Can you try '=' sign like $(=vMetricBU_B_RM), may be it will first calculate it before expansion.