Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
alan_grn
Creator II
Creator II

Variable syntax

I have a function in an expression which gives me the correct values in a pivot chart.

Is it possible to change this to a variable and then reference the variable in the chart? The syntax is below:

=

fieldvalue( 'Description', if([End Date]-[Start Date]=1,1,if([End Date]-AddMonths([Start Date],1)<0,2,if([End Date]-AddMonths([Start Date],3)<0,3,if([End Date]-AddMonths([Start Date],3)<0,4,5)))) )





Is it possible to then use this in a laod script as well? Start date and End dates are aliases as I am loading a csv file. Description is a field in another table.

4 Replies
Not applicable

I create variables in the load script like:

SET vBlueDC = '[DEBIT CODE] = 8036 or [DEBIT CODE] = 1100 or ([DEBIT CODE] >= 4100 and [DEBIT CODE] <= 4109)';

then reference it in the script like this:

if ($(vBlueDC), 'Blue' ,

I also create variables like this in the script:

SET vPartStdDisc = if ([Line Type] = 'P',
if (vRqdOrFull=0, round(([Reqd Qty]*Qty)*(([Std Retail Price]/[Pack Size])*((100 - [Addl Parts Disc%]) / 100)), 0.01),
round(ceil(([Reqd Qty]* Qty)/[Pack Size])*([Std Retail Price]*((100 - [Addl Parts Disc%]) / 100)), 0.01)), ;

which I can use in chart expressions like:

sum(
$(vPartStdDisc)
$(vLabStdDisc)
$(vMileStdDisc)
$(vTravelStdDisc)
0))))) * ((100 - [Order Disc%]) / 100)

alan_grn
Creator II
Creator II
Author

Thanks that is great it works.

Is it possibel to set up a variable to accept a paramater? I am trying to format a field to a date so wold like to have a variable which you could pass start date or end date to.

alan_grn
Creator II
Creator II
Author

Sorry I have messed it up now. I think that is was working before but doe snot do so anymore. I have a table with Product (in this exampl there is only one product) The Variable then uses start and end date, but if I only have product and the variable in the chart it only shows one item, whereas when I enter customer ID it shows the vlaue correctly. What do I need to do to show the chart with Product Nam eand then the grouings for the values returned by the variable?

alan_grn
Creator II
Creator II
Author

Have got it workign again