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

Create a Set of Tuples #25

Closed
an5ir opened this issue Feb 21, 2022 · 2 comments
Closed

Create a Set of Tuples #25

an5ir opened this issue Feb 21, 2022 · 2 comments

Comments

@an5ir
Copy link

an5ir commented Feb 21, 2022

Hi is there a way to create A set of tuples for example using mdxpy:

SELECT   
  {([Customer].[Country].[Australia], [Product].[Product Line].[Mountain]),
   ([Customer].[Country].[USA], [[Product].[Product Line].[Road])}
ON 0   
FROM [Adventure Works]  
WHERE Measures.[Internet Sales Amount]  

regards,

Ansir

@MariusWirtz
Copy link
Collaborator

Here are two ways to do it:

from mdxpy import MdxBuilder, MdxTuple

query = MdxBuilder.from_cube("Adventure works")
query.add_member_tuple_to_columns(MdxTuple.of(
    "[Australia].[Country].[Australia]",
    "[Product].[Product Line].[Mountain]"))
query.add_member_tuple_to_columns(MdxTuple.of(
    "[Australia].[Country].[USA]",
    "[Product].[Product Line].[Road]"))
mdx = query.to_mdx()

print(mdx)
from mdxpy import MdxBuilder, MdxTuple, Member

query = MdxBuilder.from_cube("Adventure works")
query.add_member_tuple_to_columns(MdxTuple.of(
    Member.of("Australia", "Country", "Australia]"),
    Member.of("Product", "Product Line", "Mountain")))
query.add_member_tuple_to_columns(MdxTuple.of(
    Member.of("Australia", "Country", "USA"),
    Member.of("Product", "Product Line", "Road]")))

mdx = query.to_mdx()

print(mdx)

@an5ir
Copy link
Author

an5ir commented Feb 21, 2022

thanks

your help is greatly appreciated.

@an5ir an5ir closed this as completed Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants