
Re: Struggling with formulas in charts
Gysbert Wassenaar Dec 2, 2012 9:33 AM (in response to yallow83)
comm67515.qvw 134.2 K

Re: Struggling with formulas in charts
yallow83 Dec 2, 2012 1:04 PM (in response to Gysbert Wassenaar )Thanks Gysbert, but I don't think it's how I wanted to analyse my data.
I have the same product (RRP  100$) sold with different prices 
Like this 
1 units for 100$
2 units for 90$ each
3 units for 80$ each
11 units for 80$ each
9 units for 80$ each
35 units for 70$ each.
This is a table I have.
Now I need to
1) Group the table above by sale price
1 units for 100$
5 units for 90$ each
20 units for 80$ each
35 units for 70$ each.
2) Show a bar chart similar to what you made but with Discounts (0%, 10%, 20%, 30%) instead of products.


Re: Struggling with formulas in charts
Or Shoham Dec 2, 2012 9:56 AM (in response to yallow83)I would suggest you calculate the discount at the script level, and then use that field as your dimension. Your expression would be sum(Qty)

Re: Struggling with formulas in charts
yallow83 Dec 2, 2012 1:06 PM (in response to Or Shoham)thanks orsh, I tried that, but it shows some discounts of 12000%. I most likely made a mistake in discount formula. Trying to fix now.

Re: Struggling with formulas in charts
yallow83 Dec 2, 2012 1:42 PM (in response to Or Shoham)Hi orsh,
Thanks!!!
Your approach works in general, but I have 2 problems 
1) (easy) my discounts are not shown as percents  it's a dimension on the graph as you recommended.
2) as you can see on the picture 10% is not exactly 10% it's sometimes 10.000001%, sometimes 9.9999%, so I need to somehow show them as the same thing.

Re: Struggling with formulas in charts
whiteline _ Dec 2, 2012 2:01 PM (in response to yallow83)Hi.
You could use round()/floor() or class() function in dimension to have 'baskets' instead of separate values:
=floor([Discount percent], 0.01)
or
=aggr(class([Discount percent], 'x', 0.01), _put here dimension that represens the selling_)
The first one can also be used in script.
In addition you could change the text format with num() to have percents:
=num(floor([Discount percent], 0.01), '0%')

