Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Bar graph coloring not applying appropriatly based on expression

I've got a stacked bar chart that I want to display, by quarter, sales for the past 2 years.

The issue I have is, coloring applies correctly to only the Year & Quarter I have currently filtered on.

How do I edit my coloring expression to fix that? Is it a set analysis issue?

variables set,

cy = max(year)

pv = max(year)-1

Dimensions:

=right(year,2)&'-Q'&qtr

=1 ---- >I have to add this obligatory dimension to make it a stacked bar, rather than a side by side bar

=category

Expression:

sum ({$ <year+={$(cy),$(pv)}, qtr+={*}>}  sales) / sum ({$ <year+={$(cy),$(pv)}, qtr+={*}>}  TOTAL <year,qtr>  dkey)

Bar chart Color Expression:

pick( match(category,'1','2','3','4'),

RGB(84,130,53),RGB(101,156,64),RGB(121,187,76),RGB(145,224,92))

12 Replies
sunny_talwar

Can you try changing your expression to this:

=Sum({<year={$(cy),$(pv)}, qtr =>} sales) / Sum({<year={$(cy),$(pv)}, qtr =>}  TOTAL <year,qtr>  dkey)


Not sure if it will make any difference, but lets start with making that change and see if it works or not.

Best,

Sunny

Not applicable
Author

Returns same data, but does not resolve coloring issue

If no year filter, all 8 bar stacks are colored appropriate

If 2014 filtered on, 13 & 14 display....but only 2014's bars are colored appropriately.

sunny_talwar

Give this a shot for color expression:

=Pick(Match(Only({1} Category),'1','2','3','4'),

RGB(84,130,53),RGB(101,156,64),RGB(121,187,76),RGB(145,224,92))

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Can you post a qvw?

Not applicable
Author

no year qtr filter I show 8 bars colored correctly

year filtered on shows no data

qtr filtered on shows data appropriatly

Not applicable
Author

I deal with sensitive data, I get real iffy about posting anything online. =\

sunny_talwar

Have you tried this both your current expression and the new expression I gave you in my first post? i.e with:

1) sum ({$ <year+={$(cy),$(pv)}, qtr+={*}>}  sales) / sum ({$ <year+={$(cy),$(pv)}, qtr+={*}>}  TOTAL <year,qtr>  dkey)


and


2) Sum({<year={$(cy),$(pv)}, qtr =>} sales) / Sum({<year={$(cy),$(pv)}, qtr =>}  TOTAL <year,qtr>  dkey)

Not applicable
Author

Tried both of those.  Data displays correctly

Colors correctly for either data filtered on, or when no filter

sunny_talwar

Colors correctly for either data filtered on, or when no filter

Not sure I understand what you are trying to say here? Can you please elaborate.

Best,

Sunny