custom count measure runs forever MDX

元气小坏坏 提交于 2020-06-17 09:07:12

问题


So this question goes off the one here

I've been trying to do a similar count measure and I did the suggested solution but it's still running.... and it's been more than 30 minutes with no results, while without that it runs in under a minute. So am I missing something? Any guidance would help. Here is my query:

WITH 
    MEMBER [Measures].[IteractionCount] AS 
    NONEMPTY
    (
        FILTER
        (
            ([DimInteraction].[InteractionId].[ALL].Children,
            [Measures].[Impression Count]),
            [DimInteraction].[Interaction State].&[Enabled]
        )
    ).count

SELECT 
(
    {[Measures].[IteractionCount],
    [Measures].[Impression Count]}
)
ON COLUMNS,
(   

    ([DimCampaign].[CampaignId].[CampaignId].MEMBERS,
     [DimCampaign].[Campaign Name].[Campaign Name].MEMBERS, 
     [DimCampaign].[Owner].[Owner].MEMBERS)
    ,[DimDate].[date].[date].MEMBERS
)
ON ROWS
FROM 
(
    SELECT 
    (
       {[DimDate].[date].&[2020-05-06T00:00:00] : [DimDate].[date].&[2020-05-27T00:00:00]}
    )
    ON COLUMNS 
    FROM [Model]
)
WHERE
(
        {[DimCampaign].[EndDate].&[2020-05-27T00:00:00]:NULL}, 
        [DimCampaign].[Campaign State].&[Active], 
        {[DimInteraction].[End Date].&[2020-05-27T00:00:00]:NULL}//,
        //[DimInteraction].[Interaction State].&[Enabled]
)     

I don't know if FILTER is affecting it in any way but I tried it with and without and it still runs forever. I do need it specifically filtered to [DimInteraction].[Interaction State].&[Enabled]. I have also tried to instead filter to that option in the WHERE clause but no luck

Any suggestions to optimize this would be greatly appreciated! thanks!

UPDATE: I end up using this query to load data into a python dataframe. Here is my code for that. I used this script for connecting and loading the data. I had to make some edits to it though to use windows authentication.

ssas_api._load_assemblies() #this uses Windows Authentication
conn = ssas_api.set_conn_string(server='server name',db_name='db name')

df = ssas_api.get_DAX(connection_string=conn, dax_string=query))

The dax_string parameter is what accepts the dax or mdx query to pull from the cube.


回答1:


Please try this optimization:


WITH 
    MEMBER [Measures].[IteractionCount] AS 
    SUM
    (
        [DimInteraction].[InteractionId].[InteractionId].Members
         * [DimInteraction].[Interaction State].&[Enabled],
         IIF(
           IsEmpty([Measures].[Impression Count]),
           Null,
           1
         )
    )

SELECT 
(
    {[Measures].[IteractionCount],
    [Measures].[Impression Count]}
)
ON COLUMNS,
(   

    ([DimCampaign].[CampaignId].[CampaignId].MEMBERS,
     [DimCampaign].[Campaign Name].[Campaign Name].MEMBERS, 
     [DimCampaign].[Owner].[Owner].MEMBERS)
    ,[DimDate].[date].[date].MEMBERS
)
PROPERTIES MEMBER_CAPTION
ON ROWS
FROM 
(
    SELECT 
    (
       {[DimDate].[date].&[2020-05-06T00:00:00] : [DimDate].[date].&[2020-05-27T00:00:00]}
    )
    ON COLUMNS 
    FROM [Model]
)
WHERE
(
        {[DimCampaign].[EndDate].&[2020-05-27T00:00:00]:NULL}, 
        [DimCampaign].[Campaign State].&[Active], 
        {[DimInteraction].[End Date].&[2020-05-27T00:00:00]:NULL}//,
        //[DimInteraction].[Interaction State].&[Enabled]
)     
CELL PROPERTIES VALUE

If that doesn’t perform well the please describe the number of rows returned by your query when you comment out IteractionCount (sic) from the columns axis. And please describe how many unique InteractionId values you have.



来源:https://stackoverflow.com/questions/62094954/custom-count-measure-runs-forever-mdx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!