MicroStrategy / mstrio-py

Python integration for MicroStrategy
Apache License 2.0
90 stars 60 forks source link

Using objects that are named the same inside a Metric/Dossier/Report. #173

Closed vladbalcanu closed 1 month ago

vladbalcanu commented 8 months ago

Inside the workstation you can pick the objects you want to use inside a Metric/Dossier/Report. That being said if you have 2 attributes named the same lets say: City, as long as you put them in separate folders you can do it. Then if you want to use one or the other inside a metric or report or dossier, you just need to pick which one. If i want to create a metric: CityMetric, that uses one of the attributes, the formula stays the same whichever i pick to use. My question is, how can i decide what attribute to use when creating a Metric with the Python API? From what i know, an error is returned usually when trying to use an attribute like this saying: More than one match returned for City.

magerdaniel commented 8 months ago

@vladbalcanu : I can follow you. I didn't do a deep dive, but you should check the REST API directly. Pls. go to your swagger page and check the following endpoint. yourserver/MicroStrategyLibrary/api-docs/index.html#/Reports/ms-getReport

Here you might find something.

vladbalcanu commented 8 months ago

Okey but i would like to know how to do it from the MicroStrategy API directly if is possible and firstly inside a metric. I did check out the Metric endpoints and they require an expression (as I said in the expression, the object's name is used. if the name is the same but it manages to get the right object then maybe there is another workflow or API endpoint that is not exposed).

magerdaniel commented 8 months ago

@vladbalcanu : Sorry for my last answer. This answer was for your other question how to address individual join types between certain metrics. I was able to create a metri using the following statement:

{ "information": { "name": "New Metric1", "destinationFolderId": "5C6A68174DC3E55B31C80EB653259E0E", "subType": "metric" }, "expression": { "tokens": [ { "value": "&Sum(Cost){~+}" } ] }}

That you need to use the name and not the ID seems to be correct. I tried to specify it closer by including the folder pass, but without success (however, I expect this is doable somehow). My first idea to fix this was, to rename fact cost, putting a unique pre or post fix, save the metric and rename the org object afterwards. Not nice, but.. hope it helps, Daniel

vladbalcanu commented 8 months ago

Yes, Using different names works. I was interested in a way to do specify the ID of the object instead maybe or the Alias. Was looking for having 2 attributes named the same but used differently. Thank you for your support.

magerdaniel commented 8 months ago

I think we should lock an EH with MSTR Support, since this is a REST API issue and not an mstrio-py issue.

apiotrowskiMicroStrategy commented 1 month ago

Not a mstrio-py issue, but REST. Closing