ModelBuilder CalculateValue into OutputName

1603
11
Jump to solution
07-18-2019 12:22 AM
StanislavaV
Occasional Contributor

hello guys,

i wanna ask you - i have tool Table to Excel in ModelBuilder but in the end i want to get XLS with output name included Date.

so i used Calculate value and as you can see it is showing correct date...but when i run my model, XLS has output name "vyber_EU".

In Calculate Value i used this expression from mr. Patterson.

time.strftime(u"zzz{0}d{0}m{0}Y".format(chr(37)))

Where is my mistake please?

0 Kudos
2 Solutions

Accepted Solutions
DuncanHornby
MVP Notable Contributor

That is your problem you are not using the output of the calculate value tool. You have made it a precondition to the table to Excel tool, we know that as it has a dotty line. Your output Excel file should be:

D:\MPRV SR\GSAA\GSAA2019\eustream\vyber_EU%output_value%.xls

If you had renamed the output of your calculate value tool to something like BOB then your output would be:

D:\MPRV SR\GSAA\GSAA2019\eustream\vyber_EU%BOB%.xls

You need to read the help file on modelbuilder in-line substitution, this is particularly important if you are using iterators.

View solution in original post

0 Kudos
DuncanHornby
MVP Notable Contributor

I think your problem is coming from you accepting default names. You have output_value, output _value (2) and %output _value%.shp  (3).

You have outputs of outputs of outputs all with subtle variation in names! So it is confusing to follow and as you are discovering confusing to program.

Looking at your model the input to table to excel is %output _value%.shp  (3) but that is not what I see in your parameter.

I suggest you STOP and take a little time (only 1 minute!) and rename your outputs with more sensible names then when you start inserting them as inline substitution it is much clearer for you to set up.

View solution in original post

11 Replies
DuncanHornby
MVP Notable Contributor

You need to show us what the Table to Excel tool is doing, you would typically use the output of the Calculate Value tool in an inline substitution in the output name of your xls file.

0 Kudos
StanislavaV
Occasional Contributor

i have shapefile like input and then i want to export XLS file from it but with date  

0 Kudos
DuncanHornby
MVP Notable Contributor

That is your problem you are not using the output of the calculate value tool. You have made it a precondition to the table to Excel tool, we know that as it has a dotty line. Your output Excel file should be:

D:\MPRV SR\GSAA\GSAA2019\eustream\vyber_EU%output_value%.xls

If you had renamed the output of your calculate value tool to something like BOB then your output would be:

D:\MPRV SR\GSAA\GSAA2019\eustream\vyber_EU%BOB%.xls

You need to read the help file on modelbuilder in-line substitution, this is particularly important if you are using iterators.

0 Kudos
StanislavaV
Occasional Contributor

thank you....:) works now

0 Kudos
StanislavaV
Occasional Contributor

i have one more question

in that model i have 2x calculate value for output name.

in the first one it says "places_DDMMYYYY" which is in results OK.

but in the second one it is set to "intersect_DDMMYYY" but in the result it is called "places_DDMMYYYY" like previous output.

what can i do to run it OK?

Thank you.

0 Kudos
DuncanHornby
MVP Notable Contributor

This is what I was trying to teach you with the BOB example. So what is the name of the output for your second calculate value tool? Is it output_value or output _value (2)? You do not have to accept default output variable names, rename it to something sensible and use that in the in-line substitution.

0 Kudos
StanislavaV
Occasional Contributor

output for second calculate value tool is this:

 

and then for copy features:

and for table to excel:

0 Kudos
DuncanHornby
MVP Notable Contributor

Look at your inline substitution, are you using %output_value% or %output _value (2)%

0 Kudos
StanislavaV
Occasional Contributor

%output_value% .... but when i tried rename it to %output_value (2)% it says that "The name contains invalid characters
Failed to execute"

0 Kudos