Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Validating User Selected Input File

carl_steinhilber
8 - Asteroid

I'm relatively new to Alteryx, but a seasoned programmer.

I'm trying to build an Analytics App that allows the user to browse for an input data file, but I would like to validate that file before processing to ensure it contains the required fields.

 

Something like:

IF input data does not contain fields [Name, Address, Date] THEN error message ELSE continue

I discovered the Field Info tool, but I'm confused how I can check the Field Input dataset for the existence of the proper fields and then return to the original Input Data dataset to continue processing. I searched pretty extensively, but the results I've found thusfar have just confused me more.  :-o

 

Thanks in advance,

-Carl

15 REPLIES 15
Claje
14 - Magnetar

Another way to accomplish this is to use a Join tool to a second dataset that just has a vertical list of the column names you care about.  Then you can run a test to ensure that the number of records is equal to the number of fields in dataset 2, rather than testing each name individually in the Test tool.

carl_steinhilber
8 - Asteroid

Thanks Claje.

 

That's another great idea.

For my project, the Input Data file can have any number of fields... and I'm only concerned with 5 or 6 of them... so your solution wouldn't work in this instance. But for future, I can see how this would be far more efficient than checking each field name!

Claje
14 - Magnetar

Hi,

I think what I proposed will work for any number of fields on either side.  I've attached a quick example here.


The Required Fields and Compared Data example is the one that should pass.  I also included a case that will fail so that you can see how it works.  Feel free to play around with this and see if it meets your need.

carl_steinhilber
8 - Asteroid

Sorry, I wasn't very clear.

What I meant was the Input Date file for this app might have 6 fields, or it might have 20, depending on how the specific user chose to export it and/or clean it. The app needs to accept both types of files (and more)... but as long as it has 4 or 5 particular fields, that's all I care about for this particular processing. So having a fixed list of fields wouldn't work (since it varies)

 

But I realize this is pretty unusual, and best practice would be for all Input Data to have the same structure... we're just not there yet.

 

Also, I could see a lot of rogue data files having x number of fields but having nothing to do with the processing I'm trying to accomplish. So if I were checking that the file has x number of fields, but I don't validate that they're the exact x fields I need, the processing would fail.

 

 

Claje
14 - Magnetar

Hi,


I think I'm understanding your use case, and I would definitely recommend taking a look at the attached.


What this will do is use an input with the 5 or 6 fields you actually care about, join against that (so that we are only looking for those fields), and then check that there are an equal number of fields that we Found, and that we were Searching for.  It won't look at any field you don't specify in the second input, and the file the user inputs could have thousands of other fields without issue.

carl_steinhilber
8 - Asteroid

Ah, I'm getting you now.

 

I'll definitely take a look!

 

Thanks!

Labels