Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

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

Thanks In Advance

1 Solution

Accepted Solutions
shraddha_g
Not applicable

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)

15 Replies
shraddha_g
Not applicable

Re: how to calculate share using variables in  qlik sense

What is the expression for Variable?

Not applicable

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)))

shraddha_g
Not applicable

Re: how to calculate share using variables in  qlik sense

what is CURR_YTD_SALES?

Not applicable

Re: how to calculate share using variables in qlik sense

I Want to show the share% of product by sales

Current Year Sales

shraddha_g
Not applicable

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?

Not applicable

Re: how to calculate share using variables in qlik sense

Variable name

shraddha_g
Not applicable

Re: how to calculate share using variables in  qlik sense

when you declare that variable what expression you used?

Not applicable

Re: how to calculate share using variables in qlik sense

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

shraddha_g
Not applicable

Re: how to calculate share using variables in  qlik sense

now expressions for these 2 variables?