@WITHATTR

The @WITHATTR calculation function for Essbase returns all base members that are associated with an attribute or varying attribute that satisfies the conditions you specify.

You can use operators such as >, <, =, and IN to specify conditions that must be met. This function can be used as a parameter of another function, where that parameter is a list of members.

Syntax

@WITHATTR (dimName, "operator", value)

Parameters

dimName

Single attribute dimension name or varying attribute dimension name.

operator

Operator specification, which must be enclosed in quotation marks ("").

value

A value that, in combination with the operator, defines the condition that must be met. The value can be an attribute member specification, a constant, or a date-format function (@TODATE).

Notes

  • A varying attribute cannot be included in a FIX command if no perspective is specified in the calculation script.

  • @WITHATTR is a superset of @ATTRIBUTE. The following two formulas return the same member set:

    @ATTRIBUTE(Bottle)
    @WITHATTR("Pkg Type","==",Bottle)

    However, the following formula can be performed only with @WITHATTR (not with @ATTRIBUTE) because you specify a condition:

    @WITHATTR(Ounces,">","16")
  • If you specify a date attribute with @WITHATTR, you must use @TODATE in the string parameter to convert the date string to a number.

    The following operators are supported:

    Table 2-33 Supported Operators

    Operator Description
    > Greater than
    >= Greater than or equal to
    < Less than
    <= Less than or equal to
    = = Equal to
    <> or != Not equal to
    IN In
  • The IN operator returns the base members that are associated with a subcategory of attributes in the attribute dimension. For example, in the Sample Basic database, @WITHATTR(Population,"IN",Medium) returns the base members that are associated with all attributes under the Medium parent member in the Population dimension.

  • When using Boolean attributes with @WITHATTR, use only the actual Boolean attribute member name, or use 1 (for True or Yes) or 0 (for False or No). You cannot use True/Yes and False/No interchangeably.

  • An operator may work differently with different attribute types. For example:

    • Text@WITHATTR(Flavors,"<",Orange) returns base members with attributes that precede Orange in the alphabet; for example, Apple, Cranberry, Mango, and Oat, but not Peach or Strawberry.

    • Boolean@WITHATTR(Caffeinated,"<",True) returns all base members that have Caffeinated set to False (or No). It does not return base members that do not have Caffeinated set to True (or Yes) or do not have a Caffeinated attribute at all. The behavior is similar for a formula like @WITHATTR(Caffeinated,"<>",True), which returns only base members with Caffeinated set to False.

    • Date@WITHATTR("Intro Date","<",@TODATE("mm-dd-yyyy","07-26-2002")) returns all base members with date attributes that are before July 26, 2002.

Example

The following table shows examples, based on the Sample Basic database, for each type of operator:

Table 2-34 Operator Results

Operator Example Result
> @WITHATTR(Population,">","18000000") Returns New York, California, and Texas
>= @WITHATTR(Population,">=",10000000) where 10,000,000 is not a numeric attribute member, but a constant Returns New York, Florida, California, Texas, Illinois, and Ohio
< @WITHATTR(Ounces,"<","16") Returns Cola, Diet Cola, Old Fashioned, Sasparilla, and Diet Cream
<= @WITHATTR("Intro Date","<=",@TODATE("mm-dd-yyyy", "04-01-2002")) Returns Cola, Diet Cola, Caffeine Free Cola, and Old Fashioned
= = @WITHATTR("Pkg Type","= =",Can) Returns Cola, Diet Cola, and Diet Cream
<> or != @WITHATTR(Caffeinated,"<>",True) Returns Caffeine Free Cola, Sasparilla, Birch Beer, Grape, Orange Strawberry
IN @WITHATTR("Population","IN",Medium) Returns Massachusetts, Florida, Illinois, and Ohio

The following two examples show @WITHATTR used in a calculation script, based on the Sample Basic database:

/* To increase by 10% the price of products that are greater than
or equal to 20 ounces */


FIX (@WITHATTR(Ounces,">=","20"))
Price = Price * 1.1;
ENDFIX
/* To increase by 10% the marketing budget for products brought
to market after a certain date */


FIX (@WITHATTR("Intro Date",">",
@TODATE("mm-dd-yyyy","06-26-1996")));
Marketing = Marketing * 1.1;
ENDFIX