Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help please with the syntax of an expression that is built in a macro

Hi,
I need a little help please with the formatting of an expression I'm attempting to build within a macro.


I have the following expression which sums the budget for a particular region. It works OK . . .


Sum({1<[Budget Budget Region] = {AF}>} Total [Budget Budget Value])


I now need to sum the budget for a particular item sales family so tried the following, which doesn't work . . .


Sum({1<[Budget Budget Item Sales Family] = {30AZ}>} Total [Budget Budget Value])


In the editor there is a wavey red line under the AZ. I think the editor is expecting a numeric value, because it starts with 30, and so doesn't expect to see the AZ. So, I tried the following which works OK . . .

Sum({1<[Budget Budget Item Sales Family] = {'30AZ'}>} Total [Budget Budget Value])

Now I need to put this in a macro. For my region code, the following works OK (don't be concerned about the remaining parts of the sum format (the "Sum({1<" and ">}Total [Budget Budget Value])") as they are added to variable vBuildString01 elsewhere) . . .

vBuildString01 = vBuildString01 + ", [Budget Budget Region] = {$(=GetFieldSelections([Sales Customer Region],',',10))}"

The equivalent for the item sales family was as follows but doesn't work . . .

vBuildString01 = vBuildString01 + ", [Budget Budget Item Sales Family] = {$(=GetFieldSelections([Sales Item Sales Family],',',4))}>})"

So, I tried the following, which seems to generate the correct text but doesn't seem to work . . .

vSalesItemSalesFamilySelections = ActiveDocument.Evaluate("GetFieldSelections([Sales Item Sales Family],',',4)")
vBuildString01 = vBuildString01 + ", [Budget Budget Item Sales Family] = {'" + vSalesItemSalesFamilySelections + "'}"

Any help would be appreciated, thanks.


Regards,
Geoff.

1 Solution

Accepted Solutions
Not applicable
Author

Hi all,

to answer my own question, in my macro, I wrote some logic to extract the item sales family selections and build them up in a variable (vSalesItemSalesFamilySelections) so that it contained the following . . .

'selection1', 'selection2', 'selection3'

Then I used the following and it worked OK!. . .

vBuildString01 = vBuildString01 + ", [Budget Budget Item Sales Family] = {" + vSalesItemSalesFamilySelections + "}"


View solution in original post

1 Reply
Not applicable
Author

Hi all,

to answer my own question, in my macro, I wrote some logic to extract the item sales family selections and build them up in a variable (vSalesItemSalesFamilySelections) so that it contained the following . . .

'selection1', 'selection2', 'selection3'

Then I used the following and it worked OK!. . .

vBuildString01 = vBuildString01 + ", [Budget Budget Item Sales Family] = {" + vSalesItemSalesFamilySelections + "}"