Tm1py: Skip zero argument in execute_mdx functions

Created on 15 Feb 2021  路  7Comments  路  Source: cubewise-code/tm1py

Describe what did you try to do with TM1py
I want to create a cellset without coordinates that point to 0 values.
There is a skip_zeros argument e.g. in execute_mdx_dataframe()
Do I still have to add Non Empty clause to my MDX if this is set by default to True?

Describe what's not working the way you expect
N/A
Version

  • TM1py 1.6.0
  • TM1 Server Version: 11.0.8

Additional context
If you encounter an error, please add the error message and the stack trace

question

All 7 comments

Nope, you don't need to add NON EMPTY.

The NON EMPTY in the MDX drives the creation of the grid/cellset in TM1.
The skip_zeros (similarly to skip_rule_derived_cells, skip_consolidated_cells) impact what cells are retrieved from the grid/cellset.

So the NON EMPTY impacts the speed of the cellset creation in TM1 and the skip arguments in TM1py function impact the speed of the data retrieval, by reducing the size of the response by skipping irrelevant cells.

Also, a zero suppressed MDX query may produce a "grid" that contains zeros.
I hope this makes sense.

It does.
In this case if I want a truly zero suppressed view I need to both add NON EMPTY and have skip_zeros = True.
Thanks

As a side question, would it be possible to have an argument that would cancel the mdx query after X seconds? That would be handy in situations where you test a query in case e.g. you forget to add Non Empty ;)

I believe you can just simply pass the timeout argument as a kwarg

tm1.cubes.get_value(timeout=30)

Yeah. You can use the timeout argument so that python would stop waiting for the response after n seconds and continue. Like this:

from TM1py import TM1Service
from TM1py.Exceptions import TM1pyTimeout

with TM1Service(address="", port=12354, ssl=True, user="admin", password="apple") as tm1:
    try:
        message_log_entries = tm1.server.get_message_log_entries(timeout=1)
        print("Successfully retrieved message log")
    except TM1pyTimeout:
        print("Ran into timeout")

However, the thread that's building the cellset in TM1 will continue to run until it completes or you abort the operation.

If you have admin permissions, you can include logic in the except block that cancels the MDX execution operation in the TM1 server after the timeout.

Thanks @rkvinoth and @MariusWirtz for your answers
Is it possible to mimic what Arc is doing when you click Cancel View Execution button? I'm able to do that without admin rights
And if yes then to incorporate that into timeout argument?

Closing this issue and reopening another one for the cancel topic

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ianboltz picture ianboltz  路  5Comments

fidong picture fidong  路  3Comments

macmaj picture macmaj  路  4Comments

hermie64 picture hermie64  路  3Comments

yyzz1010 picture yyzz1010  路  3Comments