Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

handling Unknown variable (check if column exists)

mathias_schnoor
11 - Bolide

Hi!

 

Is it solution to check if a column exists or not and go ahead with the calculation only if the column exists?

 

By my example I use the Cross Tab Tool and my output columns are variable.

And so it is possible that a column is not always in the output but if exists in the output than make a calculation.

 

At the moment I get the error message from the Formula Tool.

 

Formula (..)   Unknown variable "<my varialble>"...

 

Mathias

6 REPLIES 6
MarqueeCrew
20 - Arcturus
20 - Arcturus
You could use field info and search for your field. If you find it you can create a variable exists = true, otherwise false. Next you can append that field to your data.

Take the data into a filter for the True data use a formula where you expect the field. For the false data use a formula that doesn't expect it.

Union the true and false (you'll only have all true or all false)

That's my idea.
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
mathias_schnoor
11 - Bolide

Hi!

 

Thank you for your support.

I have try to build a workflow and following your instructions.

 

But in result set I get to many rows.  It would be great if you have a look and make a suggestion fore the right solution.

 

Mathias

 

 

 

MarqueeCrew
20 - Arcturus
20 - Arcturus
I will build one in a couple of hours for you.
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
MarqueeCrew
20 - Arcturus
20 - Arcturus

@mathias_schnoor,

 

I am attaching the updated flow here, but have a question for you.  Is the file layout consistent except for 'FOO'?   There is an easy approach for that.  If the field list looks like:

 

{Foo, Bah, Blubber} or {Bah, Blubber}, then you can create a sample row of data using a text input (like you did already) and UNION it together with your input tool (set your text file as the 1st file in (specific output order configuration).  You can then SAMPLE and SKIP the first record.  If Foo exists, it will have it's value and if Foo is absent, it will become NULL.

 

You can then handle the formula based upon IIF(isnull([Foo],0,[Foo})

 

Just a thought.

 

You can PM me and we can chat on skype or webex.

 

Thanks,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
mathias_schnoor
11 - Bolide

@MarqueeCrew

 

Hi,

 

I have tested you solution it works great.

I have expanded your solution without Foo column.

The expansion closer than how I will use it in the future!

Mabe your question was responded already.

It would be nice if you can have a look on it!?!

 

I have a question still to you:

What is the advantage to use the Detour Tools? The result is always the same.

 

Mathias

Juda
6 - Meteoroid

hey Marquee, 

 

can you please guide me, I am creating a path for each day of current month, if the day doesn't exist yet, I would the system no to create it.

 

please your thoughts?

 

Thanks

 

Juan

Labels
Top Solution Authors