Using macro to edit filter
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi all,
I created a macro that connects to our SharePoint Online instance and generates a list of files and folders in a particular folder. At the end of the workflow, I added a drop down to allow users to filter the results: Both Files & Folders, Files Only, or Folders Only. In my data stream, I have a variable [type] which is indicates if it is a file or folder, and this is what I would like to filter on. Unfortunately after a few different attempts, I'm not sure how to construct my formula.
I attached a simple version of this workflow and was hoping someone could take a look at it for me.
I tried using the following formulas in the action tool and wrote this:
IF [#1]="both" THEN 1 ELSEIF [#1] = "files" THEN "[type] = files" ELSEIF [#1] = "folders" THEN "[type] = folders" ELSE 0 ENDIF
It doesn't seem right that I put [type] in quotes
IF [#1]="both" THEN 1 ELSEIF [#1] = "files" THEN [type] = "files" ELSEIF [#1] = "folders" THEN [type] = "folders" ELSE 0 ENDIF
Both of these formulas failed, and I'm not sure what other steps I can take to resolve this.
EDIT:
I decided to go another route and set the value of the drop down to a variable, then that way I could use [type] in my formula, but now I'm getting error messages about how "both" is an unknown variable. Maybe it's the formula/drop down list that messing me up. This attempt is formula macro2.yxzp
Solved! Go to Solution.
- Labels:
- Common Use Cases
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I think the attached is what you are looking for.
Notice that the Drop-Down interface element is directly connected into the Filter tool's "Q" input, and the wire/line is named "Filter", this name can be set by clicking on the wire/line, and in the configuration window setting the name.
Then in the Formula tool, there is a new variable section called "Connections from Questions", this is that "Q" input, and we can see "Filter" there, and it will be a string, ready to use i your expression.
If the value you were passing into the "Q" should be a number, would would need to wrap it in a ToNumber() function.
Edit: Also your expression could be simplified to just:
[Filter] = "both" OR [type] = [Filter]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks Joe, this is exactly what I was missing. I've never used the Q anchor, by any chance know the name of the "Q" symbol? I've tryied to look it up in Alteryx documentation, but I can't seem to find it, or how it differs from the lightning bolt anchor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Sometimes I see it called the Question connector, for example, if you expand "Variables" on https://help.alteryx.com/11.5/index.htm#Reference/expressionbox.htm
"
- Connections from Questions: Values from an Interface tool connected to the Question anchor of a tool with an expression editor, when the tool is used in an app or macro. Use the Question anchor when you want question values to be used as variables in the expression. See Interface Tools.
"
Other places call it the Input/Output: https://help.alteryx.com/11.5/index.htm#Interface_Tools.htm%3FTocPath%3DTools%7CTool%2520Categories%... for more details.
