Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I am trying to build a bar chart using class(). The simplified version already works and is basically designed like this:
Dimensions:
Measure:
Now I want to be able to modify the prices of some brands for simulations. For that, I introduced two more variables that can be set by the user:
Let’s assume vBrand is 'BrandA' and vMultiplier is 0.5, then I want to show the prices of BrandA reduced by 50%, and all other brands with their original prices.
To incorporate this in the bar chart, I tried to modify the Stack expression:
class([Price] * pick(wildmatch([Brand], '$(vBrand)' + 1, 1, $(vMultiplier)), $(vBucketSize))
This term works just fine in all other charts I use in my app, only the bar chart with class() refuses to work. It seems to me that a row-level modification in the first parameter of class() is not possible!? I can multiply with a single factor like class([Price]*0.5, $(vBucketSize)) which changes all prices, but as soon as I try to adapt the multiplication based on a field, I always get: The chart is not displayed because it contains only undefined values.
I would really appreciate any help.
Thanks!
Exemplary data:
Brand |
Price |
Volume |
BrandA |
90 |
24 |
BrandA |
120 |
12 |
BrandB |
100 |
50 |
BrandC |
80 |
40 |
P.S.:
I am using pick(wildmatch()) and not a simple if(), because I want to be able to add more variables for brands & multipliers, like vBrand1, vBrand2, … However, I also tested this with a simple *if([Brand]='$(vBrand)', $(vMultiplier), 1) and got the same results.
The +1 at the end of wildmatch is to make sure that all brands that are not selected for vBrand are multiplied by 1 (i.e., no change to their prices).
I assume you missed respectively (intentionally) skipped Brand as dimension within the bar-chart. Without it as dimension the call of Brand and/or Price without using an aggregation will return NULL. In this case you will need to add the wanted dimensionality to your calculated dimension, maybe with something like this:
class(aggr([Price] * pick(wildmatch([Brand], '$(vBrand)' + 1, 1, $(vMultiplier)), Brand), $(vBucketSize))
Thanks for your reply!
I have tried that, still doesn't work. Played around with aggr() quite a lot, but found no solution.
I now have also tried to do the same chart as a Vizlib Bar Chart. And there, the original term simply works. No aggr() or any other adaptions needed. However, the Vizlib chart has other restrictions, so I would still prefer to use the normal Bar Chart.