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

Stacked bar chart and count expression showing two instead of one

Hi!

I have a stacked bar chart that shows the number of units (paper machines in this case). The problem is that when one unit has multiple characteristics in the right cyclic group (major grade in this case), the x-axes shows one unit as two. Is there a way to get the calculation show correctly only one unit in x-axes?   

Onebecomestwowhenstacked.PNG

Thank you!

Regards,

Heidi

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This looks like a data model problem. I suggest that you post a sample qvd file with a subset of the real data that exhibits the problem for accurate diagnosis. At the very minimum, post your expression and a diagram of your data model.

In the meantime, do you perform a join in the load that is adding data records due to a non-unique key? Or does the expression span tables with different granularity levels?

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi Jonathan!

Here is a simple qvw-file that shows the problem. Line1 has two MajorGrade-types so the x-axes shows two eventhough the calculation gives one. My data loads from one excel file that has multiple lines per unit if it is connected to different types of grades.

Does this help? 

Reg,

Heidi

jagan
Luminary Alumni
Luminary Alumni

Hi,

You are using Dimension as MajorGrade as Dimension and Line1 is applicable for both the MajorGrades.  In chart the distinct count is calculated by Dimension, that is why you are getting Line1 in both the MajorGrades and getting count as 2. 

If you remove MajorGrade, then your count will be 1 only.  To solve this you can mark the first entry to one of the MajorGrades in script and use the Sum of it in the expression

Temp:

load * inline [

Name, MajorGrade, Area

Line1, Market, EMEA

Line1, Tissue, EMEA

Line2, Market, EMEA

];

Data:

NoConcatenate

LOAD

*,

If(Peek(Name) <> Name, 1, 0) AS Count

RESIDENT Temp

ORDER BY Name, Area, MajorGrade;

DROP TABLE Temp;

Now in chart use below expression

Sum(Count)

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Hi Jagan!

but if I mark the line to one major grade, and use it in calculations, the other major grade doesn't "show" anymore? Or does it?

jagan
Luminary Alumni
Luminary Alumni

I think removing the MajorGrade dimension is the best option, you can no way solve this by using the two dimensions.  Because Line1 is applicable to both the Major Grades.


It is up to you to choose which option you are going with.


Regards,

Jagan.