Showing posts with label association. Show all posts
Showing posts with label association. Show all posts

Tuesday, March 20, 2012

No "Existing" word... How?

I am rendering an Association Rules on Report Services. How do I make to filter the word "Existing", just like example below? I want to show attribute name only.

Pneu ML Road = Existing, Sport-100 = Existing -> Road Tubo de Pneu = Existing

to

Pneu ML Road, Sport-100 -> Road Tubo de Pneu

By the way I am using this code:

SELECT NODE_DESCRIPTION,ROUND(NODE_PROBABILITY,2)AS Probabilidade,ROUND(MSOLAP_NODE_SCORE,2)AS Importancia
from [Association].CONTENT
where NODE_TYPE=8

NODE_DESCRIPTION is a string field generated by the algorithm. It contains predicates having the form "Attribute = value" which, in the case of nested table keys, translate to "Road Tubo = Existing".

The "Existing" keyword cannot be removed from the NODE_DESCRIPTION. However, it is coming from the server's string resources. That means, if you install a localized version of the server, you will get a localized version of Existing. Furthermore, the server will attempt to "localize" the Existing string to the thread locales of the client application, as long as the respective resources are available on the server side.

Now, to get rid completely of the Existing keyword, there are a few ways:

- write a server side stored procedure which: traverses the rules in the model content, extracts the node unique names for the itemsets as well as the attribute states, then generates a string which contains the attribute name but not the value (pretty much what the stored procedures used by the built-in viewer do).

Then, invoke the stored procedure with a CALL statement.

OR:

- write a very simple C# class library, containing a single function, Replace, which takes 3 strings as arguments

string Replace(string source, string oldValue, string newValue)

{

return source.Replace(oldValue, newValue);

}

Then, deploy the assembly on the server and change your query like below:

SELECT MyAssembly.Replace(NODE_DESCRIPTION, '= Existing', ''),ROUND(NODE_PROBABILITY,2)AS Probabilidade,ROUND(MSOLAP_NODE_SCORE,2)AS Importancia
from [Association].CONTENT
where NODE_TYPE=8

While not as reliable as the first solution, this is much easier to implement and will generally work correctly, as long as the only attributes in your model are the nested table keys .

|||

You did inspired me, but I found a better solution:

Just click right button on the table, click in "Expression" and change the code Fields!Regra.Value to =Replace(Fields!Regra.Value," = Existing","")

Thank you very much!