Closed glenoconnor closed 7 years ago
Hi,
What you are getting is the proper Memberuniquename. This is by design. Cell-data in the TM1 REST API is linked to Members, not Elements.
This is because data, that comes through the TM1 REST API, is arranged in cellsets. Cellsets conist of axes and cells. The axes consist of tuples of members.
I agree, it would be more convenient if the REST API gave us the element unique names instead of the member unique name. But there is yet no way to query values with their corresponding coordinates as Element unique names. Or at least I am not aware of any.
For now the only way to go is to convert member unique names to element names in python. It's pretty straightforward:
from TM1py.Services import TM1Service
with TM1Service(address='', port=12354, user='admin', password='apple', ssl=True) as tm1:
mdx = 'SELECT TM1SubsetToSet([plan_source],"budget")*TM1SubsetToSet([plan_exchange_rates],"local exchange rate")*TM1SubsetToSet([plan_version],"FY 2004 Budget")*{[plan_department].Members}*TM1SubsetToSet([plan_business_unit],"n level business unit")*TM1SubsetToSet([plan_chart_of_accounts],"n level accounts") on ROWS, TM1SubsetToSet([plan_time],"n level 2005 time") on COLUMNS FROM [Plan_BudgetPlan]'
cellset = tm1.data.execute_mdx(mdx)
new_cellset = {}
for members, cell in cellset.items():
elements = tuple([member.split('].[')[-1].split('^')[-1][0:-1] for member in members])
new_cellset[elements] = cell
print(new_cellset)
Hope it helps!
Cheers,
Marius
Actually I was wrong. The TM1 REST API does allow to query cells with their coordinates in the Element Unique Name format! I updated the execute_mdx function. We will push the changes to TM1py at the of the week.
Thanks for bringing it to my attention.
Fantastic! Thanks for looking into it so quickly. Thanks for the work-around code (useful for other things I'm sure) and including a change in the next push. Looking forward to using the resulting dataframe to create some time series forecasting and putting it back. This makes it easy.
Are you using scikit-learn for the time series forecasting?
We're not using anything yet.
I wanted to know I could move the data easily. If it's going to work for us long term, I wanted a way to make it work efficiently. Your module is what we were looking for.
We're also relatively new to Python.
I will say that scikit has come-up in our research - machine learning related as I recall.
If that's a good way to go, we'll look at that first.
By the way, can I suggest you put a link to the samples on your main github page for TM1py. It's a little hard to find once you jump into the TM1py page.
From: Marius Wirtz notifications@github.com Sent: Wednesday, August 30, 2017 4:02:19 PM To: MariusWirtz-cubewise/TM1py Cc: glenoconnor; Author Subject: Re: [MariusWirtz-cubewise/TM1py] Elements with multiple parents - extra label info (#24)
Are you using scikit-learn for the time series forecasting?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/MariusWirtz-cubewise/TM1py/issues/24#issuecomment-326143003, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ad9fqj58i9HTVsUkWdjYi2wbz7N9DweRks5sden6gaJpZM4PFVpe.
I pushed the changes to the Repo. It should be fixed now.
To upgrade to the latest version of TM1py just run
pip install TM1py --upgrade
in your cmd
Thanks for the Feedback regarding the samples. I put a link in the readme.
Excellent - looks perfect now.
From: Marius Wirtz notifications@github.com Sent: Thursday, August 31, 2017 10:58:44 PM To: MariusWirtz-cubewise/TM1py Cc: glenoconnor; Author Subject: Re: [MariusWirtz-cubewise/TM1py] Elements with multiple parents - extra label info (#24)
I pushed the changes to the Repo. It should be fixed now. To upgrade to the latest version of TM1py just run pip install TM1py --upgrade in your cmd
Thanks for the Feedback regarding the samples. I put a link in the readme.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/MariusWirtz-cubewise/TM1py/issues/24#issuecomment-326495935, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ad9fqvcEuNuuDdXSOzSW6bQHBfJwWsExks5sd50UgaJpZM4PFVpe.
Quick follow-up... We're using the statsmodels.api module to create predictive forecasts using the Ordinary Least Squares model (OLS). It's probably not the most accurate model but it's a model that our forecasters can understand easily and provide the necessary input. It takes only a few seconds for TM1py to pull out a few years of daily results and load it into a DataFrame. We combine it with some predictors from an excel spreadsheet, apply the OLS model to it all and TM1py writes it back to the cube. It's painless and incredibly efficient. I expect this will create huge time savings for our company.
Nice one @glenoconnor
I'm very interested to know a bit more about the predictive forecast application you built with TM1py.
It would be great if we could either create a new sample or publish an article which could help other people to use predictive forecast with their TM1 application.
Please feel free to contact me via email: vviau@cubewise.com if you need some help to create a new sample or to write an article.
Cheers,
Hi, Thanks for creating this package! We will be using it in several ways. We're new to Python - so this issue may not really be an issue:
When an element has more than one parent, the data.execute_mdx method pulls in unwanted hierarchy information. For example, we have an element '2017-01-15' with more than one parent. It comes through as: '2017-01^2017-01-15' In this case, '2017-01-15' directly rolls into: '2017-01', 'WE 2017-01-21' and 'All Days'
If '2017-01' rolls into more than one parent, you'll get another level of the hierarchy.
When an element has only one parent, it comes through as desired '2017-01-15' I can reproduce this issue in any dimension for any element - it just needs to roll into more than one parent. Is this a bug? or is there a way to not get the unwanted hierarchy info?
Here's my MDX statement... mdx = "SELECT {[Dailies Digital - Metrics].[Customer Traffic Volume], \ [Dailies Digital - Metrics].[Cart Starts Customer]} ON Columns, \ tm1filterbylevel(Descendants([Glance - Date].[2017]),0) ON Rows \ FROM [Dailies Digital] \ Where ([Dailies Digital - Version].[Actuals])"