Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Partner - Master III
Partner - Master III

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)

View solution in original post

15 Replies
shraddha_g
Partner - Master III
Partner - Master III

What is the expression for Variable?

Not applicable
Author

This is the expression

But I am not able to get the share%

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

shraddha_g
Partner - Master III
Partner - Master III

what is CURR_YTD_SALES?

Not applicable
Author

I Want to show the share% of product by sales

Current Year Sales

shraddha_g
Partner - Master III
Partner - Master III

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
Author

Variable name

shraddha_g
Partner - Master III
Partner - Master III

when you declare that variable what expression you used?

Not applicable
Author

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

shraddha_g
Partner - Master III
Partner - Master III

now expressions for these 2 variables?