Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am trying to use parameterized variable with rgb color as a parameter. It seems the comma in the RGB() function is causing the issue and the expression is not working.
I have using this expression in the attached app to give background color to the dimension in chart.
=$(vVar(rgb(241,82,73))) //Not working
vVar =if(sum(Sales) < 110,rgb(241,82,73)) //Actual expression
Please help!
You can't pass a parameter that includes commas in the value. The commas are always interpreted as parameter separators. What you can do is add a DSE to calculate the numeric value of the RGB code and pass that. Like this:
=$(vVar($(=num(rgb(241,82,73)))))
Because RGB returns a Dual, you must extract the num otherwise QV will attempt to pass the string representation. This is true even if you use script created variables.
LET vColor = RBG(1,2,3);
LET vColorNum = num(RGB(1,2,3));
$(vVar($(vColor))) // won't work
$(vVar($(vColorNum))) // will work
Update: Actually, a color variable with a LET will work if you pass it as a direct reference, no DSE.
$(vVar(vColor)) // will work
That's because variables passed as parameters like this will be passed by reference, not value.
-Rob
May be create variable like
If($1=1, If(sum(Sales) < 110,rgb(241,82,73)))
BG Color like $(vVar(1))
Hi Anil...Thanks for your reply.
I am creating this parameterised variable to improve the performance of my real expression which is different.
I am looking to have the RGB function directly in the variable as a parameter. Do you think its not possible.
Thanks!
Yes, I am thinking about how we can overcome this issue. May be stalwar1 help you
You can't pass a parameter that includes commas in the value. The commas are always interpreted as parameter separators. What you can do is add a DSE to calculate the numeric value of the RGB code and pass that. Like this:
=$(vVar($(=num(rgb(241,82,73)))))
Because RGB returns a Dual, you must extract the num otherwise QV will attempt to pass the string representation. This is true even if you use script created variables.
LET vColor = RBG(1,2,3);
LET vColorNum = num(RGB(1,2,3));
$(vVar($(vColor))) // won't work
$(vVar($(vColorNum))) // will work
Update: Actually, a color variable with a LET will work if you pass it as a direct reference, no DSE.
$(vVar(vColor)) // will work
That's because variables passed as parameters like this will be passed by reference, not value.
-Rob
Check if the attached works for you
Thanks you so much for the solution and the explanation..rockstar