# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for
Did you mean:
Highlighted 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

1 Solution

Accepted Solutions
Highlighted Partner

## 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
Highlighted Partner

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

What is the expression for Variable?

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

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

what is CURR_YTD_SALES?

Highlighted 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

Highlighted Partner

## 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?

Highlighted Not applicable

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

Variable name

Highlighted Partner

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

when you declare that variable what expression you used?

Highlighted Not applicable

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

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

Highlighted Partner

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

now expressions for these 2 variables?