Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mangled code blocks #9995

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 40 additions & 70 deletions docs/mdx/avg-mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,79 +47,49 @@ Avg( Set_Expression [ , Numeric_Expression ] )
## Examples
The following example returns the average for a measure over a specified set. Notice that the specified measure can be either the default measure for the members of the specified set or a specified measure.

`WITH SET [NW Region] AS`

`{[Geography].[State-Province].[Washington]`

`, [Geography].[State-Province].[Oregon]`

`, [Geography].[State-Province].[Idaho]}`

`MEMBER [Geography].[Geography].[NW Region Avg] AS`

`AVG ([NW Region]`

`--Uncomment the line below to get an average by Reseller Gross Profit Margin`

`--otherwise the average will be by whatever the default measure is in the cube,`

`--or whatever measure is specified in the query`

`--, [Measures].[Reseller Gross Profit Margin]`

`)`

`SELECT [Date].[Calendar Year].[Calendar Year].Members ON 0`

`FROM [Adventure Works]`

`WHERE ([Geography].[Geography].[NW Region Avg])`
```
WITH SET [NW Region] AS
{[Geography].[State-Province].[Washington]
, [Geography].[State-Province].[Oregon]
, [Geography].[State-Province].[Idaho]}
MEMBER [Geography].[Geography].[NW Region Avg] AS
AVG ([NW Region]
--Uncomment the line below to get an average by Reseller Gross Profit Margin
--otherwise the average will be by whatever the default measure is in the cube,
--or whatever measure is specified in the query
--, [Measures].[Reseller Gross Profit Margin]
)
SELECT [Date].[Calendar Year].[Calendar Year].Members ON 0
FROM [Adventure Works]
WHERE ([Geography].[Geography].[NW Region Avg])
```

The following example returns the daily average of the `Measures.[Gross Profit Margin]` measure, calculated across the days of each month in the 2003 fiscal year, from the **Adventure Works** cube. The **Avg** function calculates the average from the set of days that are contained in each month of the `[Ship Date].[Fiscal Time]` hierarchy. The first version of the calculation shows the default behavior of Avg in excluding days that did not record any sales from the average, the second version shows how to include days with no sales in the average.

`WITH MEMBER Measures.[Avg Gross Profit Margin] AS`

`Avg(`

`Descendants(`

`[Ship Date].[Fiscal].CurrentMember,`

`[Ship Date].[Fiscal].[Date]`

`),`

`Measures.[Gross Profit Margin]`

`), format_String='percent'`

`MEMBER Measures.[Avg Gross Profit Margin Including Empty Days] AS`

`Avg(`

`Descendants(`

`[Ship Date].[Fiscal].CurrentMember,`

`[Ship Date].[Fiscal].[Date]`

`),`

`CoalesceEmpty(Measures.[Gross Profit Margin],0)`

`), Format_String='percent'`

`SELECT`

`{Measures.[Avg Gross Profit Margin],Measures.[Avg Gross Profit Margin Including Empty Days]} ON COLUMNS,`

`[Ship Date].[Fiscal].[Fiscal Year].Members ON ROWS`

`FROM`

`[Adventure Works]`

`WHERE([Product].[Product Categories].[Product].&[344])`
```
WITH MEMBER Measures.[Avg Gross Profit Margin] AS
Avg(
Descendants(
[Ship Date].[Fiscal].CurrentMember,
[Ship Date].[Fiscal].[Date]
),
Measures.[Gross Profit Margin]
), format_String='percent'
MEMBER Measures.[Avg Gross Profit Margin Including Empty Days] AS
Avg(
Descendants(
[Ship Date].[Fiscal].CurrentMember,
[Ship Date].[Fiscal].[Date]
),
CoalesceEmpty(Measures.[Gross Profit Margin],0)
), Format_String='percent'
SELECT
{Measures.[Avg Gross Profit Margin],Measures.[Avg Gross Profit Margin Including Empty Days]} ON COLUMNS,
[Ship Date].[Fiscal].[Fiscal Year].Members ON ROWS
FROM
[Adventure Works]
WHERE([Product].[Product Categories].[Product].&[344])
```

The following example returns the daily average of the `Measures.[Gross Profit Margin]` measure, calculated across the days of each semester in the 2003 fiscal year, from the **Adventure Works** cube.

Expand Down
32 changes: 14 additions & 18 deletions docs/mdx/axis-mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,23 @@ Axis(Axis_Number)
## Examples
The following example query shows how to use the Axis function:

`WITH MEMBER MEASURES.AXISDEMO AS`

`SETTOSTR(AXIS(1))`

`SELECT MEASURES.AXISDEMO ON 0,`

`[Date].[Calendar Year].MEMBERS ON 1`

`FROM [Adventure Works]`
```
WITH MEMBER MEASURES.AXISDEMO AS
SETTOSTR(AXIS(1))
SELECT MEASURES.AXISDEMO ON 0,
[Date].[Calendar Year].MEMBERS ON 1
FROM [Adventure Works]
```

The following example shows the use of the Axis function inside a calculated member:

`WITH MEMBER MEASURES.AXISDEMO AS`

`SUM(AXIS(1), [Measures].[Internet Sales Amount])`

`SELECT {[Measures].[Internet Sales Amount],MEASURES.AXISDEMO} ON 0,`

`{[Date].[Calendar Year].&[2003], [Date].[Calendar Year].&[2004]} ON 1`

`FROM [Adventure Works]`
```
WITH MEMBER MEASURES.AXISDEMO AS
SUM(AXIS(1), [Measures].[Internet Sales Amount])
SELECT {[Measures].[Internet Sales Amount],MEASURES.AXISDEMO} ON 0,
{[Date].[Calendar Year].&[2003], [Date].[Calendar Year].&[2004]} ON 1
FROM [Adventure Works]
```

## See Also
[MDX Function Reference (MDX)](../mdx/mdx-function-reference-mdx.md)
Expand Down
28 changes: 11 additions & 17 deletions docs/mdx/bottomsum-mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,17 @@ BottomSum(Set_Expression, Value, Numeric_Expression)
## Examples
The following example returns, for the Bike category, the smallest set of members of the City level in the Geography hierarchy in the Geography dimension for fiscal year 2003, and whose cumulative total, using the Reseller Sales Amount measure, is at least the sum of 50,000 (beginning with the members of this set with the smallest number of sales):

`SELECT`

`[Product].[Product Categories].Bikes ON 0,`

`BottomSum`

`({[Geography].[Geography].[City].Members}`

`, 50000`

`, ([Measures].[Reseller Sales Amount],[Product].[Product Categories].Bikes)`

`) ON 1`

`FROM [Adventure Works]`

`WHERE([Measures].[Reseller Sales Amount],[Date].[Fiscal].[Fiscal Year].[FY 2003])`
```
SELECT
[Product].[Product Categories].Bikes ON 0,
BottomSum
({[Geography].[Geography].[City].Members}
, 50000
, ([Measures].[Reseller Sales Amount],[Product].[Product Categories].Bikes)
) ON 1
FROM [Adventure Works]
WHERE([Measures].[Reseller Sales Amount],[Date].[Fiscal].[Fiscal Year].[FY 2003])
```

## See Also
[MDX Function Reference (MDX)](../mdx/mdx-function-reference-mdx.md)
Expand Down
59 changes: 23 additions & 36 deletions docs/mdx/crossjoin-mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,32 @@ Set_Expression1 * Set_Expression2 [* ...n]
## Examples
The following query shows simple examples of the use of the Crossjoin function on the Columns and Rows axis of a query:

`SELECT`

`[Customer].[Country].Members *`

`[Customer].[State-Province].Members`

`ON 0,`

`Crossjoin(`

`[Date].[Calendar Year].Members,`

`[Product].[Category].[Category].Members)`

`ON 1`

`FROM [Adventure Works]`

`WHERE Measures.[Internet Sales Amount]`
```
SELECT
[Customer].[Country].Members *
[Customer].[State-Province].Members
ON 0,
Crossjoin(
[Date].[Calendar Year].Members,
[Product].[Category].[Category].Members)
ON 1
FROM [Adventure Works]
WHERE Measures.[Internet Sales Amount]
```

The following example shows the automatic filtering that takes place when different hierarchies from the same dimension are crossjoined:

`SELECT`

`Measures.[Internet Sales Amount]`

`ON 0,`

`//Only the dates in Calendar Years 2003 and 2004 will be returned here`

`Crossjoin(`

`{[Date].[Calendar Year].&[2003], [Date].[Calendar Year].&[2004]},`

`[Date].[Date].[Date].Members)`

`ON 1`

`FROM [Adventure Works]`
```
SELECT
Measures.[Internet Sales Amount]
ON 0,
//Only the dates in Calendar Years 2003 and 2004 will be returned here
Crossjoin(
{[Date].[Calendar Year].&[2003], [Date].[Calendar Year].&[2004]},
[Date].[Date].[Date].Members)
ON 1
FROM [Adventure Works]
```

The following three examples return the same results - the Internet Sales Amount by state for states within the United States. The first two use the two cross join syntaxes and the third demonstrates the use of the WHERE clause to return the same information.

Expand Down
37 changes: 14 additions & 23 deletions docs/mdx/current-mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,20 @@ Set_Expression.Current
## Examples
The following example shows how to use the **Current** function inside **Generate**:

`WITH`

`//Creates a set of tuples consisting of all Calendar Years crossjoined with`

`//all Product Categories`

`SET MyTuples AS CROSSJOIN(`

`[Date].[Calendar Year].[Calendar Year].MEMBERS,`

`[Product].[Category].[Category].MEMBERS)`

`//Iterates through each tuple in the set and returns the name of the Calendar`

`//Year in each tuple`

`MEMBER MEASURES.CURRENTDEMO AS`

`GENERATE(MyTuples, MyTuples.CURRENT.ITEM(0).NAME, ", ")`

`SELECT MEASURES.CURRENTDEMO ON 0`

`FROM [Adventure Works]`
```
WITH
//Creates a set of tuples consisting of all Calendar Years crossjoined with
//all Product Categories
SET MyTuples AS CROSSJOIN(
[Date].[Calendar Year].[Calendar Year].MEMBERS,
[Product].[Category].[Category].MEMBERS)
//Iterates through each tuple in the set and returns the name of the Calendar
//Year in each tuple
MEMBER MEASURES.CURRENTDEMO AS
GENERATE(MyTuples, MyTuples.CURRENT.ITEM(0).NAME, ", ")
SELECT MEASURES.CURRENTDEMO ON 0
FROM [Adventure Works]
```

## See Also
[MDX Function Reference (MDX)](../mdx/mdx-function-reference-mdx.md)
Expand Down
16 changes: 7 additions & 9 deletions docs/mdx/currentordinal-mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ Set_Expression.CurrentOrdinal
## Examples
The following simple example shows how **CurrentOrdinal** can be used with **Generate** to return a string containing the name of each item in a set along with its position in the set:

`WITH SET MySet AS [Customer].[Customer Geography].[Country].MEMBERS`

`MEMBER MEASURES.CURRENTORDINALDEMO AS`

`GENERATE(MySet, CSTR(MySet.CURRENTORDINAL) + ") " + MySet.CURRENT.ITEM(0).NAME, ", ")`

`SELECT MEASURES.CURRENTORDINALDEMO ON 0`

`FROM [Adventure Works]`
```
WITH SET MySet AS [Customer].[Customer Geography].[Country].MEMBERS
MEMBER MEASURES.CURRENTORDINALDEMO AS
GENERATE(MySet, CSTR(MySet.CURRENTORDINAL) + ") " + MySet.CURRENT.ITEM(0).NAME, ", ")
SELECT MEASURES.CURRENTORDINALDEMO ON 0
FROM [Adventure Works]
```

The practical use of CurrentOrdinal is limited to very complex calculations. The following example returns the number of products in the set that are unique, using the **Order** function to order the non-empty tuples before utilizing the **Filter** function. The **CurrentOrdinal** function is used to compare and eliminate ties.

Expand Down
38 changes: 16 additions & 22 deletions docs/mdx/descendants-mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,25 @@ Descendants(Set_Expression [ , Distance [ ,Desc_Flag ] ] )

If no level or distance is specified, the default value for the level used by the function is determined by calling the [Level](../mdx/level-mdx.md) function (<\<Member>>.Level) for the specified member (if a member is specified) or by calling the **Level** function for each member of the specified set (if a set is specified). If no level expression, distance or flags are specified, the function performs as if the following syntax were used:

`Descendants`

`(`

`Member_Expression ,`

`Member_Expression.Level ,`

`SELF_BEFORE_AFTER`

`)`
```
Descendants
(
Member_Expression ,
Member_Expression.Level ,
SELF_BEFORE_AFTER
)
```

If a level is specified and a description flag is not specified, the function performs as if the following syntax were used.

`Descendants`

`(`

`Member_Expression ,`

`Level_Expression,`

`SELF`

`)`
```
Descendants
(
Member_Expression ,
Level_Expression,
SELF
)
```

By changing the value of the description flag, you can include or exclude descendants at the specified level or distance, the children before or after the specified level or distance (until the leaf node), and the leaf children regardless of the specified level or distance. The following table describes the flags allowed in the *Desc_Flag* argument.

Expand Down
Loading