Variable Y

0 views
Skip to first unread message

Catherine Nicolo

unread,
Aug 5, 2024, 10:41:31 AM8/5/24
to mifiveremp
Inprogramming, a variable is a value that can change, depending on conditions or on information passed to the program. Typically, a program consists of instruction s that tell the computer what to do and data that the program uses when it is running. The data consists of constants or fixed values that never change and variable values (which are usually initialized to "0" or some default value because the actual values will be supplied by a program's user). Usually, both constants and variables are defined as certain data type s. Each data type prescribes and limits the form of the data. Examples of data types include: an integer expressed as a decimal number, or a string of text characters, usually limited in length.

In object-oriented programming , each object contains the data variables of the class it is an instance of. The object's method s are designed to handle the actual values that are supplied to the object when the object is being used.


I understand this is a needed feature, but as a workaround, you can use plug-ins to export the JSON structure, change it, and import it back, while moving between collections is not implemented natively. There even are some web-based WYSWYG tools that will show a JSON file structured as tree view so you can move nodes arround.


However, I would also like to be able to copy or move variables to another file. I thought it would work since you already are able to multi select them but there seems to be no copy or cut option yet.


I have a screen with 5 buttons in it, all with variables. I was able to copy/paste the screen to another file and all of the variables carried over. When I copy/paste the screen within the same file and same page, all of the variables were cleared out. This might be a bug? This behavior makes no sense.


Since all of these are new, we are experimenting to find the best practice for organizing variables, sometimes we decide to change our system to make a better one. This option can help to get things even faster


Update: splitting a collection would be also a great help if my previous request has some implementation challenges. Only if we could move some parts of a Collection into a new Collection. (or maybe, turning a group into a collection)


Good remark @Natalie_Doronina , but maybe we can imagine a way to move from collection to collection, warning the user he will lose the mode information if a mismatch, or a UI to do vairable mode values mapping from collection to collection.


@Michal_Krendzelak exactly. I think it could be also good if there were an option, to split a collection (instead of moving variables to some other collection) this way, the challenge of different value settings would be gone, and help us to reshape our system


I have a batch macro that is creating summary tables that get written to multiple Excel workbooks along with the associated raw detailed data. It is a batch macro because I am creating 1 summary/detailed output for multiple different groups of data.


I am trying to create some conditional formatting rules with the summary table tools to color cells based on different values within those particular fields, however, those field names change with each batch! So I can't just create the rules based on the 1st batch of data I am building the macro with, I need the rules to be dynamic.


I found this article in the community ( -Designer-Discussions/How-to-Color-Column-values-in-Alteryx-...) that was looking like it was going to work, but now I keep getting this error on the table tool: "String variable switched type".


I've checked the incoming data types and those columns are all set to V_Strings, so really not sure how/why they are switching types within the table tool itself...anyone else have experience with this error and/or a solution?


I would suggest building some dynamic field re-mapping into the batch macro. Start out by taking your input fields, and renaming them to a consistent set of fields for all your formatting to work, then renaming those fields with the original names in the Table output after the formatting is complete. This would work if you have a consistent field schema, just different names, between all the outputs.


"but Charlie, how can I replace field names in a table field that's already created?" I'm glad you asked. This is possible by editing the raw PCXML of the Layout field.



Let me know if this seems like a path that could work for you and we can dive into that process.


Also, the other thread mentioned setting up a "Apply" Formula using the [_CurrentField_]=="x" condition. This is a string test, which may be an issue. I would try and use [_CurrentFieldName_] variable to define when to apply a Column Rule. This was you could set up one rule of each type, then update the list of fields it applies to each time by replacing the target this [_CurrentFieldName_] is set to.


I added "[_CurrentFieldName_] in (...)" to my [_CurrentField_]=="x" logic and the error is no more!!! However, the conditional formatting is still not applying correctly, it seems to be coloring the values all willy-nilly. Interestingly enough, there appears to be a pattern where the formatting is only being applied to the latter half of my columns...like if I were to shift the coloring to the beginning of these columns in the table it would be accurate. Looking into that a bit more now.


So, I was able to figure out the dynamic rules based on that 1st article I linked, your recommendation here worked to stop the table tool from throwing that "String field switched type" error, BUT the coloring/formatting is still not accurate. At least we are making steps in the right direction?


How about, if we can't figure out the formatting in the Reporting tools, using Alteryx to kick off the application of those formatting rules in Excel? Check out the article below to see how a Run Command tool could use CScript.exe to run VBA macros that could execute that formatting automatically.


I was struggling with the same problem for hours and I realised that the report tool seems to be working with all fields no matter I specifically select one column. So if you have multiple types of fields in the input of the table tool and you want to apply condition with "[_CurrentField_]" on numeric field, it will not work. However it will work if you only have numeric type of data in your input table. So my question now whether I can somehow join the other types of columns into the same table once I generated the table only with numeric fields. Any idea? :)


That extraction is working as intended the problem is that I want to access each one inside a For each action and I already have a variable named 'Counter' starting at '0' and incrementing with each iteration of the loop.


Since all my variables start with 'LinkCMVMConsulta' and then have a number in front of them changing I was thinking of appending the 'Counter' to the text 'LinkCMVMConsulta' and use it as a variable, not as a string, and I have not been able to do so.


I know that is the correct way the variable should be written, that is why I wanted to write it like this LinkCMVMConsulta + Counter. So it would automatically change the variable to the correct one for each iteration of the loop I'm running. Without a way to write the variable dynamically I guess I will have to use a bunch of If and Else to get the correct output I want


I just wanted to comment that this is pretty annoying. I have a large workflow and just hit a bug where a "Java Edit Variable" node was assuming that a flow variable was new. But then I created a variable far upstream with the same name. Now that node crashes. It would have been much better if I could have deleted that flow variable upstream after I was done using it.


You may have figured this out already, but the workaround I use whenever I create a new variable with a Java Snippet node that might be used multiple times in a workflow is to precede the JS node with a Java Edit Variable node. The Java Edit Var node should be configured to create a new variable of the same type and name of the variable in the Java Snippet node. Connect the Java Edit Var node to the left "mickey mouse ear" i.e. flow variable inport of the Java Snippet node. Now when you add the same named output variable in the Java Snippet node it should be configured to replace the already existing variable instead of create a new variable. This prevents you from getting the error about the JS node trying to create a new variable that already exists.


One more point... apparently the "Sub Node" feature (which as similar to the Meta Node feature) will prevent variables from leaking from the contained nodes. There isn't much documentation yet but I understand from KNIME folks that more support is coming and eventually sub nodes will be preferred to meta nodes.


Thanks for your reply. I would use the Sub Node feature in order to prevent variable leakage, but the problem is that a Meta Node is configurable whereas a Sub Node can't be configured. In general, most of my Meta Nodes have configuration parameters.


Right now I have a growing number of flow variables. It would be nice to have something like the Column Filter node but for flow variables, so that I will only see the variables that I think I need for further downstream processing.


I use a wrapped node, which protects the scope of any flow variables within it, and use quickform nodes to provide configuration options. These allows for parameters and selections of input table values.


I have found that with this any corruption of flow variable from different parts of the workflows can be prevented. I also use call local workflow node to create factories so I can have a generic workflow that passes control to local workflows to deal with anything specific. This keeps the scope of the flow variables precise to where it is needed.


Certainly, wrapped nodes/metanodes can help, but they don't always provide what I want. Sometimes I want to export a specific variable from a metanode while discarding all other variables. I don't think this currently possible.

3a8082e126
Reply all
Reply to author
Forward
0 new messages