Syntax & Structure
Learn PXL’s simple but powerful syntax for creating data transformations and text analysis expressions.
Language Overview
Section titled “Language Overview”PXL is a focused expression language designed for:
- Data filtering with complex conditions
- Text analysis using AI-powered functions
- Data distribution analysis with quantiles
- Function chaining for multi-step transformations
Basic Expression Structure
Section titled “Basic Expression Structure”Single Function Calls
Section titled “Single Function Calls”filter(revenue > 1000)extract("email addresses" from customer_notes)score(review_text from "bad" to "excellent")classify(feedback into ("positive", "negative", "neutral"))ntile(sales_amount, 4)word_count(description)Function Chaining
Section titled “Function Chaining”Use the -> operator to chain function outputs:
filter(customer_type is "premium") ->extract("product mentions" from feedback_text)
filter(order_date after "2024-01-01") ->score(satisfaction_survey from "dissatisfied" to "satisfied")Identifiers and Literals
Section titled “Identifiers and Literals”Column Identifiers
Section titled “Column Identifiers”Reference dataset columns by name:
customer_idorder_datetotal_revenuecustomer_typeproduct_nameSpecial Identifier
Section titled “Special Identifier”The $ symbol refers to the current dataset:
$ // Represents the current datasetString Literals
Section titled “String Literals”Strings must be enclosed in double quotes:
"premium""2024-01-01""iPhone""email addresses"Numeric Literals
Section titled “Numeric Literals”Numbers support integers, decimals, and scientific notation:
42123.45-51.2e6Temporal Literals
Section titled “Temporal Literals”Dates use ISO format:
"2024-01-01" // Date only"2024-01-01T12:30:00" // Date and timeBoolean Literals
Section titled “Boolean Literals”truefalseTRUE // Case insensitiveFALSENull Literal
Section titled “Null Literal”nullOperators
Section titled “Operators”Comparison Operators
Section titled “Comparison Operators”// Numeric comparisonsrevenue > 1000age >= 18score < 50rating <= 5price == 99.99quantity != 0
// String equalitystatus is "active"category is not "discontinued"
// Pattern matchingemail like "%.com"product not like "old%"Set Operators
Section titled “Set Operators”// Membership testingregion in ("US", "Canada", "Mexico")status not in ("cancelled", "refunded")priority in (1, 2, 3)
// Text containmentdescription contains "premium"Temporal Operators
Section titled “Temporal Operators”// Date/time comparisonscreated_date after "2024-01-01"expiry_date before "2024-12-31"event_date between "2024-01-01" and "2024-03-31"Boolean Operators
Section titled “Boolean Operators”// Logical ANDrevenue > 1000 and customer_type is "premium"
// Logical ORstatus is "active" or last_login after "2024-01-01"
// Complex combinations with parenthesesage >= 18 and (country is "US" or country is "CA")Filter Expressions
Section titled “Filter Expressions”Simple Conditions
Section titled “Simple Conditions”filter(active == true)filter(revenue > 10000)filter(customer_tier is "gold")Complex Boolean Logic
Section titled “Complex Boolean Logic”filter( revenue > 5000 and customer_type is "enterprise" and (region is "US" or region is "EU"))
filter( status is "active" or (status is "trial" and signup_date after "2024-01-01"))Null Handling
Section titled “Null Handling”filter(email is not null)filter(phone_number is null)filter(middle_name is not "")Text Analysis Syntax
Section titled “Text Analysis Syntax”Extract Function
Section titled “Extract Function”extract("description" from column_name)
// Examplesextract("email addresses" from contact_info)extract("dollar amounts" from transaction_notes)extract("phone numbers" from customer_data)Classify Function
Section titled “Classify Function”// Simple categoriesclassify(text_column into ("category1", "category2", "category3"))
// Categories with descriptionsclassify(feedback_text into ( "positive": "happy, satisfied, great experience", "negative": "frustrated, disappointed, problems", "neutral": "factual, no strong emotion"))Score Function
Section titled “Score Function”score(text_column from "negative_pole" to "positive_pole")
// Examplesscore(reviews from "terrible" to "amazing")score(feedback from "angry" to "delighted")Word Count Function
Section titled “Word Count Function”word_count(text_column)
// Examplesword_count(description)word_count(customer_comments)Data Distribution
Section titled “Data Distribution”Ntile Function
Section titled “Ntile Function”ntile(numeric_column, number_of_tiles)
// Examplesntile(revenue, 4) // Quartilesntile(age, 10) // Decilesntile(score, 100) // PercentilesGrouping and Precedence
Section titled “Grouping and Precedence”Parentheses for Grouping
Section titled “Parentheses for Grouping”// Boolean logic groupingfilter((age >= 18 and age <= 65) or status is "exempt")
// Function parametersfilter(region in ("US", "CA", "MX"))
// List definitionsclassify(text into ("positive", "negative", "neutral"))Operator Precedence
Section titled “Operator Precedence”- Parentheses
()- Highest precedence - Comparison operators
>,<,>=,<=,==,!=,is,like - Set operators
in,contains - Boolean AND
and - Boolean OR
or- Lowest precedence
// These are equivalent:filter(age > 18 and status is "active" or type is "vip")filter(((age > 18) and (status is "active")) or (type is "vip"))Comments
Section titled “Comments”PXL supports single-line comments:
// Filter for active premium customersfilter(status is "active" and tier is "premium")
extract("product names" from reviews) // Extract mentioned productsExpression Chaining
Section titled “Expression Chaining”Simple Chaining
Section titled “Simple Chaining”data -> filter(active == true) -> ntile(revenue, 4)Multi-Step Chaining
Section titled “Multi-Step Chaining”customer_data ->filter(signup_date after "2024-01-01") ->classify(feedback into ("satisfied", "neutral", "unsatisfied")) ->filter(classify_result is "satisfied")Syntax Rules
Section titled “Syntax Rules”Case Sensitivity
Section titled “Case Sensitivity”- Keywords are case-insensitive:
AND,and,Andare equivalent - Column names are case-sensitive:
CustomerID≠customerid - String literals are case-sensitive:
"Premium"≠"premium"
Whitespace
Section titled “Whitespace”Whitespace is generally ignored:
// These are equivalentfilter(revenue>1000and status is"active")filter(revenue > 1000 and status is "active")Required Elements
Section titled “Required Elements”- Function names are required and cannot be omitted
- Parentheses are required for function calls
- Double quotes are required for string literals
- Operators must be properly spaced in some contexts
Common Syntax Patterns
Section titled “Common Syntax Patterns”Data Filtering Patterns
Section titled “Data Filtering Patterns”// Date range filteringfilter(order_date between "2024-01-01" and "2024-12-31")
// Multi-condition filteringfilter(amount > 100 and currency is "USD" and status is "paid")
// Category filteringfilter(product_category in ("electronics", "books", "clothing"))Text Analysis Patterns
Section titled “Text Analysis Patterns”// Sentiment analysis workflowfilter(review_date after "2024-01-01") ->score(review_text from "disappointed" to "thrilled")
// Content classificationfilter(content_type is "support_ticket") ->classify(message_text into ("technical", "billing", "general"))Data Exploration Patterns
Section titled “Data Exploration Patterns”// Revenue quartile analysisfilter(customer_type is "enterprise") ->ntile(annual_revenue, 4)
// Text length analysisfilter(has_description == true) ->word_count(product_description)Error Prevention
Section titled “Error Prevention”Quote Strings Properly
Section titled “Quote Strings Properly”// ❌ Incorrectfilter(status is active)
// ✅ Correctfilter(status is "active")Use Correct Date Format
Section titled “Use Correct Date Format”// ❌ Incorrectfilter(date after "01/15/2024")
// ✅ Correctfilter(date after "2024-01-15")Include Function Parentheses
Section titled “Include Function Parentheses”// ❌ Incorrectfilter revenue > 1000
// ✅ Correctfilter(revenue > 1000)Match Parentheses and Quotes
Section titled “Match Parentheses and Quotes”// ❌ Incorrect - missing closing quotefilter(status is "active)
// ❌ Incorrect - missing closing parenthesisfilter(revenue > 1000
// ✅ Correctfilter(status is "active")What’s Next?
Section titled “What’s Next?”Function Reference
Learn the details of each PXL function with examples and best practices.
Advanced Techniques
Master complex patterns and optimization strategies for sophisticated analysis.