Skip to main content

Creating a Calculated Member

Creating a Calculated Member

To create one or more calculated members within a query, use syntax as follows:

WITH with_clause1 with_clause2 ... SELECT query_details
Tip:

Notice that you do not include commas between the clauses.

Where:

  • Each expression with_clause1, with_clause2, and so on has the following syntax:

    MEMBER MEASURES.[new_measure_name] AS 'value_expression'
    

    Later sections of this page discuss value_expression.

  • query_details is your MDX query.

Then your query can refer the calculated member by name in all the places where you can use other members.

For example:

WITH MEMBER MEASURES.avgage AS 'MEASURES.[age]/MEASURES.[%COUNT]' 
SELECT MEASURES.avgage ON 0, diagd.diagnoses.members ON 1 FROM demomdx
 
                                    avgage
1 None                                33.24
2 asthma                              34.79
3 CHD                                 67.49
4 diabetes                            57.24
5 osteoporosis                        79.46
Note:

This calculated member is a query-scoped calculated member; its scope is the query. For information on session-scoped calculated members, see CREATE MEMBER Statement, in the InterSystems MDX Reference.

FeedbackOpens in a new tab