locked
Wild Card Serach in MDX whiel querying cube RRS feed

  • Question

  • Dear All,

     I want to put the user search function in  parameter section where our UI is connencted to SSAS cube. This couls be wildcard search as well.  I am aware that we can  search for a substring in a MDX query. But do we have an option to search for individual characters like the once we perform in SQL queries?

    For example if my product names are :  MMA11, MMB21,MMC11, MMD51 and if my users want to search all of them with single input parameters like MM??1 where '??' are wild card replacement for single characters. This will give me all the products with the names 'MMxx1' without any other products with extra characters.

    Is this is possible to make?

    Thanks in advance,

    Wednesday, October 24, 2018 12:53 PM

Answers

  • Hi PXPRXR,

    You can still use the filter combined with left() and right() function to achieve this goal.

    For example: get customer name which start with A and end with g from Adventure Works cube.

    SELECT {} ON COLUMNS
        , FILTER([Customer].[Customer].[Customer]
            , Left([Customer].[Customer].MEMBER_NAME, 1) = "A" and Right([Customer].[Customer].MEMBER_NAME, 1) = "g") ON ROWS
    FROM [Adventure Works];
    

    Regards,

    Pirlo Zhang 


    MSDN Community Support<br/> Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact <a href="mailto:MSDNFSF@microsoft.com">MSDNFSF@microsoft.com</a>.

    • Proposed as answer by Pirlo Zhang Monday, October 29, 2018 9:39 AM
    • Marked as answer by PXPRXR Monday, October 29, 2018 2:38 PM
    Thursday, October 25, 2018 8:50 AM

All replies

  • Hello,

    For this you can use the InStr or Filter function in MDX, see Wild Card in MDX Queries


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    • Proposed as answer by Pirlo Zhang Thursday, October 25, 2018 3:08 AM
    Wednesday, October 24, 2018 1:15 PM
  • Hello,

    Thanks for your quick reply. I know this is possible.

    InStr([Dim Grp].[Dim Name].MEMBER_NAME, "xxx") <> 0

    To search a specific character/string

    But I want know if this possible to search with specific characters. Something like this:

    InStr([Dim Grp].[Dim Name].MEMBER_NAME, "x?x" <> 0

    Where this has to return anything with the string 'xxx' like the first one but dynamically replaces any charactes for '?'. In other words the character '?' itself is a wildcard search.Is this is possible?

    Regards,

    Thursday, October 25, 2018 7:01 AM
  • Hi PXPRXR,

    You can still use the filter combined with left() and right() function to achieve this goal.

    For example: get customer name which start with A and end with g from Adventure Works cube.

    SELECT {} ON COLUMNS
        , FILTER([Customer].[Customer].[Customer]
            , Left([Customer].[Customer].MEMBER_NAME, 1) = "A" and Right([Customer].[Customer].MEMBER_NAME, 1) = "g") ON ROWS
    FROM [Adventure Works];
    

    Regards,

    Pirlo Zhang 


    MSDN Community Support&lt;br/&gt; Please remember to click &amp;quot;Mark as Answer&amp;quot; the responses that resolved your issue, and to click &amp;quot;Unmark as Answer&amp;quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact &lt;a href=&quot;mailto:MSDNFSF@microsoft.com&quot;&gt;MSDNFSF@microsoft.com&lt;/a&gt;.

    • Proposed as answer by Pirlo Zhang Monday, October 29, 2018 9:39 AM
    • Marked as answer by PXPRXR Monday, October 29, 2018 2:38 PM
    Thursday, October 25, 2018 8:50 AM