Alter cube dimension by using XMLA - ssas

By using XMLA how to access WriteEnabled dimension property and modify it?
Here is a sample I'm using for that
<Alter ObjectExpansion="ExpandFull" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<Object>
<DatabaseID>DB</DatabaseID>
<DimensionID>My dimension</DimensionID>
</Object>
<ObjectDefinition>
<Dimension xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2"
xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100">
<WriteEnabled>false</WriteEnabled>
<ID>My dimension</ID>
<Name>Dimension name</Name>
<Attributes>
<Attribute>
<Name>Attribute name/Name>
</Attribute>
</Attributes>
</Dimension>
</ObjectDefinition>
</Alter>
Running this script I'm getting following error: Errors in the metadata manager. The 'My dimension' dimension has either zero or multiple key attributes.
What is missing in a script above?

Seems the key columns node and Name columns nodes for your attribute have missing:
Here is an example for a dim attributes node, hope it helps:
You can create a cube manually, and then check the alter script by right click the cube name for a reference also.

Related

How to import a column from SQL into Excel via BIML

I would like to import column 'Street' (NVARCHAR(50)) from a SQL table (Practice2.dbo.Adress) into Excel (ExcelDestination.xls). I know how to do this in SSIS, but in BIML I can't seem to find the right code, especially to do the column mapping between source and destination. When I try to generate the SSIS package, I get the error
"Could not resolve reference to 'Adress' of type 'TableResource'. 'TableName="Adress"' is invalid. Provide valid scoped name."
Here is what I have done so far:
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<OleDbConnection Name="ConnectionWithPractice2" ConnectionString="Provider='SQLNCLI11'; Data Source='DWH'; Initial Catalog='Practice2'; User Id='system'; Password='password';"></OleDbConnection>
<ExcelConnection Name="Excel Connection Manager" ConnectionString="Provider='Microsoft.Jet.OLEDB.4.0';Data Source='C:\Users\adm-jpna\Documents\ExcelDestination.xls';Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'">
</ExcelConnection>
</Connections>
<Packages>
<Package Name="Package1">
<Tasks>
<Dataflow Name="ImportIntoExcel">
<Transformations>
<OleDbSource Name="OLE_DB_Source" ConnectionName="ConnectionWithPractice2">
<DirectInput>SELECT Street FROM Practice2.dbo.Adress</DirectInput>
</OleDbSource>
<ExcelDestination Name="Excel_Destination" ConnectionName="Excel Connection Manager">
<Columns>
<Column SourceColumn="Street"></Column>
</Columns>
<TableOutput TableName="Adress"></TableOutput>
</ExcelDestination>
</Transformations>
</Dataflow>
</Tasks>
</Package>
</Packages>
I made a few minor changes to your ExcelDestination
<Package Name="so_45063165">
<Tasks>
<Dataflow Name="ImportIntoExcel">
<Transformations>
<OleDbSource Name="OLE_DB_Source" ConnectionName="ConnectionWithPractice2">
<DirectInput>SELECT N'123 Oak' AS Street;</DirectInput>
</OleDbSource>
<ExcelDestination Name="Excel_Destination" ConnectionName="Excel Connection Manager">
<ExternalTableOutput Table="Sheet1$" />
</ExcelDestination>
</Transformations>
</Dataflow>
</Tasks>
</Package>
TableOutput refers to the Biml collection of Tables. You're looking for ExternalTableOutput which instructs the engine to look to the referred object (Excel in this case) to validate that it exists. The change in tag results in the property changing from TableName to Table and then since we're referencing a worksheet and not a table, we need to specify as such with a $. Sheet1 would be a table or named ranged while Sheet1$ means the actual worksheet.
Since you didn't provide a column mapping between your source Street and a target column, I removed the tags.

Document id reference desn't work for impex

I have a problem with impex which contains document id reference.
From docs:
"Especially for importing partOf item values it is necessary to reference these items by means other than the usual unique column technique because partOf items often do not provide a unique key but only hold their enclosing parent as foreign key."
Items from *items.xml (only the most important parts)
<itemtype code="A" autocreate="true" generate="true" abstract="true"/>
<itemtype code="B" autocreate="true" generate="true" extends="A">
<deployment table="btable" typecode="20115" />
<attributes>
<attribute qualifier="code" type="java.lang.Integer" autocreate="true" generate="true">
<persistence type="property"/>
<modifiers optional="false"/>
</attribute>
</attributes>
</itemtype>
<itemtype code="C" autocreate="true" generate="true">
<deployment table="ctable" typecode="20117" />
<attributes>
<attribute qualifier="code" type="java.lang.String" autocreate="true" generate="true">
<persistence type="property"/>
<modifiers optional="false" unique="true"/>
</attribute>
<attribute qualifier="test" type="A" autocreate="true" generate="true">
<persistence type="property"/>
<modifiers optional="false" partof="true"/>
</attribute>
</attributes>
</itemtype>
Impex code:
INSERT B;code;&docIdRef
;1;docId
INSERT_UPDATE C;code[unique=true];test(&docIdRef)
;uniqueCode;docId
Error message:
cannot create C with values ItemAttributeMap[ registry: null, type: <null>, (...) due to [de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator#3b777877]:missing values for [test] in model C
When I removed 'partof' modifier from 'test' attribute (C class) everything worked fine.
I wonder how impex should looks like if i want to keep 'partof' modifier.
When you use partOf you must reference the partOf using the owner.
So it does :
INSERT B;owner(C.code);&docIdRef
;uniqueCode;docId
INSERT_UPDATE C;code[unique=true];test(&docIdRef)
;uniqueCode;docId
You don't need to assign B an identifier, you just need to reference the owner.
If you know for sure that your data is correct you can use [forceWrite=true] modifier or legacy mode to skip service layer validation.
You should also make sure that this configuration is what you really need. Setting either optional to true or partOf to false or providing default value should fix the issue as well.
Since you have mentioned partof="true" you can not assign a reference of type A. You can only create a new entity.
Check the OOTB AbstractOrder2AbstractOrderEntry relationship, they have mentioned partof="true" for AbstractOrderEntry means you can't reference any other AbstractOrderEntry to Order. You can always create new entry.
Have a look at HMC site as well
You can see here there is no + Add Entry button available here. The reciprocal can be possible.

Is it possible to create multiple data source objects under the same database executing a single xmla script?

I want to create multiple data source objects under the same database executing the single XMLA script only once.I have tried the below script but it did not work.If I define only a single node, the script executes successfully.But when I add the another same node it gives error. I am newer to this.Please guide.
<Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ParentObject>
<DatabaseID>Test Database</DatabaseID>
</ParentObject>
<ObjectDefinition>
<DataSource xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RelationalDataSource">
<ID>Test Datasource1</ID>
<Name>Test Datasource1</Name>
<Description>A test datasource1.</Description>
<ConnectionString>Provider=SQLNCLI11.1;Data Source=servername;User ID=user;Password=pass;Initial Catalog=SqlDb</ConnectionString>
<ImpersonationInfo>
<ImpersonationMode>ImpersonateServiceAccount</ImpersonationMode>
</ImpersonationInfo>
<Timeout>PT0S</Timeout>
</DataSource>
<DataSource xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RelationalDataSource">
<ID>Test Datasource2</ID>
<Name>Test Datasource2</Name>
<Description>A test datasource2.</Description>
<ConnectionString>Provider=SQLNCLI11.1;Data Source=servername;User ID=user;Password=pass;Initial Catalog=SqlDb</ConnectionString>
<ImpersonationInfo>
<ImpersonationMode>ImpersonateServiceAccount</ImpersonationMode>
</ImpersonationInfo>
<Timeout>PT0S</Timeout>
</DataSource>
</ObjectDefinition>
</Create>
Is there a batch element wrapper you can use?

SSRS can't use "Required Attendees" in dataset?

I am creating report in SSRS for CRM. I have a table with Dataset for Appointment info and I noticed that it does not allow me to report on required attendees??? Is this true? If so is there a workaround around this? I basically want my report to show appointments details and of course who participated.
Any advice is much appreciated!
Below is the fetchXML I gathered from using Advanced Find in CRM 2013.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="appointment">
<attribute name="subject"/>
<attribute name="statecode"/>
<attribute name="scheduledstart"/>
<attribute name="activityid"/>
<attribute name="instancetypecode"/>
**<attribute name="requiredattendees"/>**
<order attribute="subject" descending="false"/>
<link-entity name="account" from="accountid" to="regardingobjectid" alias="ae">
<filter type="and">
<condition attribute="accountid" operator="eq" value="#name"/>
</filter>
</link-entity>
</entity>
</fetch>
To get this information you will have to create another one datasource and retrieve information from ActivityParty entity. All items like requiredattendees, optionalattendees in appointment, from, to, cc, bcc in email, e.t.c. are stored inside ActivityParty entity.

SSAS - Is it possible to add an attribute to an existing dimension w/o redeploying the entire cube

I have a dimension Entity with just Key and Value attributes. We need to add a new attribute, IsSpecial with a default member of [False].
When I try to run the xmla, I get the following error:
Errors in the metadata manager. The
cube with the ID of 'X', Name
of 'Y' was invalidated by
operations in the transaction.
Here's a fragment of the XMLA used to alter the dimension
<Dimension>
<ID>Dim Entity</ID>
<Name>Entity</Name>
<UnknownMemberName>Unknown</UnknownMemberName>
<Attributes>
<Attribute>
<ID>Dim Entity</ID>
<Name>Entity</Name>
<Usage>Key</Usage>
<EstimatedCount>119</EstimatedCount>
<KeyColumns>
<KeyColumn>
<DataType>Integer</DataType>
<Source xsi:type="ColumnBinding">
<TableID>shared_DimEntity</TableID>
<ColumnID>EntityKey</ColumnID>
</Source>
</KeyColumn>
</KeyColumns>
<NameColumn>
<DataType>WChar</DataType>
<DataSize>32</DataSize>
<Source xsi:type="ColumnBinding">
<TableID>shared_DimEntity</TableID>
<ColumnID>EntityValue</ColumnID>
</Source>
</NameColumn>
<AttributeRelationships>
<AttributeRelationship>
<AttributeID>IsSpecial</AttributeID>
<Name>IsSpecial</Name>
</AttributeRelationship>
</AttributeRelationships>
</Attribute>
<Attribute>
<ID>IsSpecial</ID>
<Name>IsSpecial</Name>
<KeyColumns>
<KeyColumn>
<DataType>Boolean</DataType>
<Source xsi:type="ColumnBinding">
<TableID>shared_DimEntity</TableID>
<ColumnID>IsShadowTracking</ColumnID>
</Source>
</KeyColumn>
</KeyColumns>
<NameColumn>
<DataType>WChar</DataType>
<Source xsi:type="ColumnBinding">
<TableID>shared_DimEntity</TableID>
<ColumnID>IsShadowTracking</ColumnID>
</Source>
</NameColumn>
<DefaultMember>[Entity].[IsSpecial].[False]</DefaultMember>
</Attribute>
</Attributes>
<Hierarchies>
<Hierarchy>
<ID>Hierarchy</ID>
<Name>Hierarchy</Name>
<Levels>
<Level>
<ID>IsSpecial</ID>
<Name>IsSpecial</Name>
<SourceAttributeID>IsSpecial</SourceAttributeID>
</Level>
</Levels>
</Hierarchy>
</Hierarchies>
</Dimension>
Any suggestions?
I doubt there is a way of doing this.
When changing dimension model you also modify cubes which use that dimension. Without redeploying the whole cube, metadata manager doesn't know about changes in cube.
The same situation occurs when changing dimensions in BIDS on-line - appropriate cubes are affected so they need to be deployed again.
"Recall that ROLAP partition-mode storage means that source data is not
copied to the SSAS destination. Another characteristic of ROLAP partition storage is that
aggregations are written back to relational tables in the source schema."
"To set a dimension as a ROLAP dimension, open the Dimension editor in BIDS, and in the Properties window for that dimension change the StorageMode property from the default MOLAP to ROLAP"
"though this requires Enterprise Ed of SSAS"