Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
azimabadi
Creator III
Creator III

How to set BGColor for Expression of Straight table in macro?

Hi all,

i to set background color of an Expression of a straight table in my macro. i can do it for an pivot table but the same code dosn't function in a straight table.

Best Regards

Peyman

1 Solution

Accepted Solutions
Siva_Sankar
Master II
Master II

syntax would be... set chart = ActiveDocument.Activesheet.CreateStraightTable chart.AddDimension "ProductType" chart.AddExpression "sum(Amount)" set cp = chart.GetProperties set expr = cp.Expressions.Item(0).Item(0).Data set bce = expr.AttributeExpressions.BkgColorExp bce.Definition.v = "if(ProductType='Soap', red(), yellow())" chart.SetProperties cp

View solution in original post

9 Replies
giakoum
Partner - Master II
Partner - Master II

Hi

Use the macro to set a variable and then use the variable to set the color in the background color expression :

if variable=1 then colorRED else colorBLUE

otherwise this will help you a lot :

http://community.qlik.com/qlikviews/1137

Siva_Sankar
Master II
Master II

Properties -> Expressions -> click on the + next to the expression -> background color -> put something like rgb(255,100,100) in the definition box.

azimabadi
Creator III
Creator III
Author

Thank you so much giakoum,

but i create my Expressions in my macro. this means there is no Expression that i can set the variable as BGColor. So i need to set the variable in BGColor property in my macro and this is the same problem i had at first.

Best Regards

Peyman

giakoum
Partner - Master II
Partner - Master II

this will help you a lot :

http://community.qlik.com/qlikviews/1137

azimabadi
Creator III
Creator III
Author

Dear Shiva,

please note that i have said i need to do this in macro, using VBScript language. The way you have mentioned is correct but only works in Interface.

Best Regards

Peyman

Siva_Sankar
Master II
Master II

In that case, follow the link below. There are much examples to set color using macros. Hope it will be helpfull for you. http://community.qlik.com/qlikviews/1137

Siva_Sankar
Master II
Master II

syntax would be... set chart = ActiveDocument.Activesheet.CreateStraightTable chart.AddDimension "ProductType" chart.AddExpression "sum(Amount)" set cp = chart.GetProperties set expr = cp.Expressions.Item(0).Item(0).Data set bce = expr.AttributeExpressions.BkgColorExp bce.Definition.v = "if(ProductType='Soap', red(), yellow())" chart.SetProperties cp

azimabadi
Creator III
Creator III
Author

Thank you so much Shiva,

it's the correct answer.

Best Regards

Peyman

azimabadi
Creator III
Creator III
Author

Thnak you giakoum,

the QVW is great and is really useful for setting properties in chart.

Best Regard

Peyman