15 Replies Latest reply: Dec 14, 2016 4:43 AM by Shraddha Gajare

# how to calculate share using variables in  qlik sense

Want to calculate Share of products but facing this problem

I Have Been Using This Expression But It Is giving me error because it cant sum up the sales

Sum(\$(CURR_YTD_SALES))/Sum(Total(\$(CURR_YTD_SALES)))

So is There a way to sum up sales by using variables to calculate Shares

• ###### Re: how to calculate share using variables in  qlik sense

What is the expression for Variable?

• ###### Re: how to calculate share using variables in  qlik sense

This is the expression

But I am not able to get the share%

Sum(\$(CURR_YTD_SALES))/Sum(Total(\$(CURR_YTD_SALES)))

• ###### Re: how to calculate share using variables in  qlik sense

what is CURR_YTD_SALES?

• ###### Re: how to calculate share using variables in  qlik sense

I Want to show the share% of product by sales

Current Year Sales

• ###### Re: how to calculate share using variables in  qlik sense

I understood u need share%.

But what is CURR_YTD_SALES?

Is it a fieldname or Variable name?

if it is a variable name then what have you it defined as?

• ###### Re: how to calculate share using variables in  qlik sense

Variable name

• ###### Re: how to calculate share using variables in  qlik sense

when you declare that variable what expression you used?

• ###### Re: how to calculate share using variables in  qlik sense

((\$(CURR_YTD_GROSS_SALES)-\$(CURR_YTD_GROSS_RETURN)))/100000

• ###### Re: how to calculate share using variables in  qlik sense

now expressions for these 2 variables?

• ###### Re: how to calculate share using variables in  qlik sense

Gross Sales

if(num(GetSelectedCount(Year_new))=0

or GetFieldSelections(Year_new)='2016' ,

sum({<[DATE_FORMAT.autoCalendar.Month]=,[DATE_FORMAT.autoCalendar.Date]=

{"\$(= '>=' & '01-04-'& (Date(monthstart(Today()), 'YYYY')) & '<=' & '30-06-'& (Date(monthstart(Today()), 'YYYY')))"}>}GROSS_SALES_VALUE),

sum({<[DATE_FORMAT.autoCalendar.Month]=,[DATE_FORMAT.autoCalendar.Date]=

{"\$(= '>=' & '01-04-'&Date(AddYears(date('01-04-'& GetFieldSelections(Year_new)),+0), 'YYYY') & '<=' & '30-06-'&Date(AddYears(date('30-06-'& GetFieldSelections(Year_new)),+0), 'YYYY'))"}>}GROSS_SALES_VALUE)

)

Similarly for Gross Return

• ###### Re: how to calculate share using variables in  qlik sense

Just try to debug each variable.

It should be

(sum(Gross sales) - sum(Gross return))/(sum(Total Gross sales) - sum(Total Gross return))

it will give you share %

• ###### Re: how to calculate share using variables in  qlik sense

its working this way but i want it dynamic thats why i used variables

but whenever i try to do the sum of a certain variable it fails

eg: in case of above variable

sum(\$CURR_YTD_SALES)/sum(total(\$CURR_YTD_SALES))

if i break down the above variable in 2 parts

1.sum(\$CURR_YTD_SALES)

2.sum(total(\$CURR_YTD_SALES))

so in both parts i cant sum up the variable

• ###### Re: how to calculate share using variables in  qlik sense

create different variable CURR_YTD_TOTAL_SALES as

if(num(GetSelectedCount(Year_new))=0

or GetFieldSelections(Year_new)='2016' ,

sum(Total {<[DATE_FORMAT.autoCalendar.Month]=,[DATE_FORMAT.autoCalendar.Date]=

{"\$(= '>=' & '01-04-'& (Date(monthstart(Today()), 'YYYY')) & '<=' & '30-06-'& (Date(monthstart(Today()), 'YYYY')))"}>}GROSS_SALES_VALUE),

sum(Total {<[DATE_FORMAT.autoCalendar.Month]=,[DATE_FORMAT.autoCalendar.Date]=

{"\$(= '>=' & '01-04-'&Date(AddYears(date('01-04-'& GetFieldSelections(Year_new)),+0), 'YYYY') & '<=' & '30-06-'&Date(AddYears(date('30-06-'& GetFieldSelections(Year_new)),+0), 'YYYY'))"}>}GROSS_SALES_VALUE)

)

and then use expression as

\$(CURR_YTD_SALES)/\$(CURR_YTD_TOTAL_SALES)

• ###### Re: how to calculate share using variables in  qlik sense

Its Working But Its Giving 0.00%

Could You Tell me Why?

• ###### Re: how to calculate share using variables in  qlik sense

Try \$(CURR_YTD_SALES) and \$(CURR_YTD_TOTAL_SALES) individually and see what values it gives?