In SQL
I like to search a column for matches of a particular string using something like this:
SELECT t.attributeNAME
FROM myTable t
WHERE t.attributeNAME LIKE '%searchString%'
I might like to use that in a temp table and then use the result in subsequent sections of a longer script like so:
--find the keys
SELECT t.attributeKEY
INTO #Temp
FROM myTable t
WHERE t.attributeNAMELIKE '%searchString%'
--use the keys
SELECT SUM(f.measure)
FROM myFacts f
INNER JOIN #Temp t ON
f.attributeKEY = t.attributeKEY
--use the keys again
SELECT SUM(F.measure)
FROM myOtherFacts F
INNER JOIN #Temp t ON
F.attributeKEY = t.attributeKEY
Is there an equivalent to this in MDX
? If I have an idea what items from a hierarchy that I'm after can I somehow use a searchString to filter to a specific set of items?
EDIT
As pointed out by Marc Polizzi answer it seems like instr
is very useful in this situation and I can do the following:
CREATE SET [xCube].[Set_Names] AS
{FILTER(
[xDimension].[xHierarchy].[xLevel].Members,
(InStr(1, [xDimension].[xHierarchy].CurrentMember.NAME, "WIL") <> 0)
)
}
GO
SELECT
NON EMPTY
[Set_Names]
ON ROWS,
NON EMPTY
[Measures].[x]
ON COLUMNS
FROM [xCube]
GO
SELECT
NON EMPTY
[Set_Names]
ON ROWS,
NON EMPTY
[Measures].[y]
ON COLUMNS
FROM [xCube]
GO
SELECT
NON EMPTY
[Set_Names]
ON ROWS,
NON EMPTY
[Measures].[z]
ON COLUMNS
FROM [xCube]
You might be able to use the Instr function even if it does not support wildcard.
There is no such thing like like
in plain MDX, but there is an implementation in the ASSP project: http://asstoredprocedures.codeplex.com/wikipage?title=StringFilters&referringTitle=Home
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With