Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

percentage in stack chart by cycle group

Hi All,

I have a problem that was in a part solved.

I'm facing an issue with the Stack bar chart where I want to show the % for each stack that is relative to the entire bar

I used this which works quite well with DIM1

Sum(Sales) / Sum(TOTAL <DIM1> Sales)

But I have a cycle group and when I use this :

Sum(Sales) / Sum(TOTAL <GetCurrentField([GroupName])> Sales)  it doesn’t work.

However the function GetCurrentField([GroupName])   is correct and return the current field used.

Please help me.

Thank you

Am’

1 Solution

Accepted Solutions
Not applicable

Re: percentage in stack chart by cycle group

I did some experiment & I believe TOTAL qualifier did not allow the expressions or may be bug. So just pass the variable or add the expression in $() or add list of fields in the group.

Approach 1:

Sum(Sales) / Sum(TOTAL <$(=GetCurrentField([GroupName]))> Sales)

Approach 2:

vFieldName = GetCurrentField([GroupName]) ;

Sum(Sales) / Sum(TOTAL <$(vFieldName)> Sales)

Approach 3:

Sum(Sales) / Sum(TOTAL <Dim1,Dim2,Dim3> Sales)

3 Replies
Not applicable

Re: percentage in stack chart by cycle group

You may be try with variable like below:

vFieldName = GetCurrentField([GroupName]) ;

Sum(Sales) / Sum(TOTAL <$(vFieldName)> Sales)


Other way is use all the Dimensions in the group in side Total like below:


Sum(Sales) / Sum(TOTAL <Dim1,Dim2,Dim3> Sales)

Not applicable

Re: percentage in stack chart by cycle group

I did some experiment & I believe TOTAL qualifier did not allow the expressions or may be bug. So just pass the variable or add the expression in $() or add list of fields in the group.

Approach 1:

Sum(Sales) / Sum(TOTAL <$(=GetCurrentField([GroupName]))> Sales)

Approach 2:

vFieldName = GetCurrentField([GroupName]) ;

Sum(Sales) / Sum(TOTAL <$(vFieldName)> Sales)

Approach 3:

Sum(Sales) / Sum(TOTAL <Dim1,Dim2,Dim3> Sales)

Not applicable

Re: percentage in stack chart by cycle group

Thank you !!