community
cancel
Showing results for 
Search instead for 
Did you mean: 
With our short, effective, relevant, and interactive lessons that include videos, activities, and quizzes, you'll be up and running in no time!
Interactive Lessons
With our short, effective, relevant, and interactive lessons that include videos, activities, and quizzes, you'll be up and running in no time!
Unable to display your progress at this time. Please try again a little later, or contact an administrator if you continue to see this error.

Writing Conditional Statements

Sr. Instructional Designer
Sr. Instructional Designer

Lesson Objective: Structure conditional statements to apply logic to data values

Estimated Time: ~13 Minutes

Description:

  • Learn to structure conditional statements in the Expression Editor
  • Create simple and multi-conditional statements to change data values
  • Explore less commonly used conditional functions
  • Quiz yourself on what you've learned!

Recommended Follow-Up: Evaluating Empty and Null Values, Preparing Data with String Functions

Comments
Atom

A minor typo of < instead of <=  in the if then else endif clause causing the condition to look incomplete

Sr. Instructional Designer
Sr. Instructional Designer

Good catch, @shashi!

screen is frozen, i cannot add my answer here.

I chose in the final question the "If/then" statement, but for some reason it said I chose the boolean statement. Why?

Tried again. No matter what I choose it says I chose Boolean.

Sr. Instructional Designer
Sr. Instructional Designer

@douglasgregory418, the "Incorrect" message for that final quiz question explains that two answers can be used to correctly answer this question, and why the other (no spoilers!) is not correct.  I hope that helps with interpretation of that message!

Meteoroid

May it helps others that need louder volume to the awesones presentations
this tool did it for me (freeware)
EqualizerAPO: http://sourceforge.net/projects/equalizerapo/

Asteroid

I think there a logical error on the If then elseif statement. The formula would assign a value of 1 to ages over 18 and under 35; this means 19 thru 34, and it would assign the value 2 to ages over 35 and under 60; this means 36 thru 59, and it would assign the value of 3 to ages over 60; this means; 61+. Thus age 35 would get the assignment of 3 and any other negative number; however, age 60 would still get the default 3.

Sr. Instructional Designer
Sr. Instructional Designer

Good catch @JORGE4900!  You're right on with the details.  For the purposes of the demonstration, the values will work but, with any more variability in the input dataset, you'd have to make some adjustments to the conditional logic. 

Asteroid

@ChristineB No worries

Meteor

 I'm new with Alteryx and all that videos are good for me to learn, thanks a lot

Sr. Instructional Designer
Sr. Instructional Designer

@AlexandreCB I'm so glad you're finding them helpful! 

Atom

Can we have the sample files to improve the effectiveness of the lessons?

Meteor

The sound cuts out in screen 3. Is there another lesson I could follow to make up for this section?

It is worth noting that people under 18 would get a value of 3, and that the 'elseif' should probablly cover the range or expected results and the else result in an error message to catch data quality issues in the data set. But good work, nicely explained.

Meteoroid

There is a bug in the second question.   I added ENDIF at the end of the statement and got my answer as incorrect. The correct answer would be to add ENDIF at the end of statement what exactly I did.

I answered the last 2 questions correctly: added the ENDIF at the end of the statement, and chose the SWITCH statement for the second question.  Both were marked incorrect.

You have a typo in this presentation at the boundary values of conditions.  For example you selected < 35 for Category "1" and > 35 for category "2".  What about = 35?  Do you see it?

Atom

-- Omitted - The 3rd question is multiple choice.

Atom

Is formula case sensitive? for 2nd question I typed elseif, and it resulted incorrect

Atom

Hello Christine,

 

The lesson is frozen on Question No.2

Cannot continue with the lesson.

The lesson was good as it introduced to some new conditional statements and how easy they are to deal with large data,

Atom

I am assuming that the IF THEN ELSEIF THEN ENDIF works similar to an SQL CASE statement in that once it encounters a TRUE condition and performs the associated THEN clause for a given record, it drops down to the ENDIF for that record (effectively moving on to commence testing the next record)?

 

Therefore in regards the Session Category formula it would be sufficient to have:

 

IF [Duration of Visit (mins)] >= 30 THEN "Long" 

ELSEIF [Duration of Visit (mins)] >= 5 THEN "Medium" 

ELSEIF [Duration of Visit (mins)] < 5 THEN "Short" 

ELSE [Duration of Visit (mins)] 

ENDIF

 

... as at the "Medium" test step the additional criteria of  AND [Duration of Visit (mins)] < 30  as presented in the slides is superfluous given records with duration >=30 would have been actioned as "Long" and not tested further.

Asteroid

Question two does not read ENDIF correction

Meteoroid

Thank you for the tutorials - very helpful