Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

How drill through works with direct query

Hello All,   Can any one please quide or clear my confusion about how drill through works with direct query?   I have create a home page with table which contains country sales and the data sourc...
  • parry2k's avatar
    parry2k
    6 years ago

    Anonymous It's a great question and as per my finding, on drill thru page, on the direct query, query fold will happen, means where clause will happen at the back end, and only required data will come to the power bi.

     

    Here is how I tested, Azure SQL Server, used direct query, on drill thru page, create a table visual from this direct query table, and added campaign and name as drill thru which are part of two another tables, agent and campaign (entered data directly in power bi, it can be import as well). One to many relationships between these two tables with direct query SQL table.

     

    Created a page, with two table visuals, added agent, and campaign in each table visual. on right-click on one of the rows in the table visual, drill thru to the page where SQL server table using a direct query is visualized. 

     

    These are the queries passed to the Azure SQL when drill thru happens

     

    //DRIL THRU USING AGENT FROM MAIN PAGE
    
    // DAX Query
    DEFINE VAR __DS0FilterTable = 
      TREATAS({"Computers"}, 'Campaign'[Campaign])
    
    EVALUATE
      TOPN(
        502,
        SUMMARIZECOLUMNS(
          ROLLUPADDISSUBTOTAL(
            ROLLUPGROUP('DimCall'[AgentName], 'DimCall'[Campaign], 'DimCall'[Company]), "IsGrandTotalRowTotal"
          ),
          __DS0FilterTable,
          "CountAgentName", CALCULATE(COUNTA('DimCall'[AgentName]))
        ),
        [IsGrandTotalRowTotal],
        0,
        'DimCall'[AgentName],
        1,
        'DimCall'[Campaign],
        1,
        'DimCall'[Company],
        1
      )
    
    ORDER BY
      [IsGrandTotalRowTotal] DESC,
      'DimCall'[AgentName],
      'DimCall'[Campaign],
      'DimCall'[Company]
    
    
    // SQL Query
    
    SELECT 
    TOP (1000001) [t0].[AgentName],[t0].[Company],
    COUNT_BIG([t0].[AgentName])
     AS [a0]
    FROM 
    (
    (select [$Table].[CallId] as [CallId],
        [$Table].[CallDate] as [CallDate],
        [$Table].[AgentName] as [AgentName],
        [$Table].[Company] as [Company],
         [$Table].[CRMCaseID] as [CRMCaseID]
    from [dbo].[DimCall] as [$Table])
    )
     AS [t0]
    WHERE 
    (
    [t0].[Campaign] = N'Computers'
    )
    
    GROUP BY [t0].[AgentName],[t0].[Company] 
    
    
    //DRIL THRU USING CAMPAIGN FROM MAIN PAGE
    
    // DAX Query
    DEFINE VAR __DS0FilterTable = 
      TREATAS({"Cedric Daughtery"}, 'Agent'[Agent])
    
    EVALUATE
      TOPN(
        502,
        SUMMARIZECOLUMNS(
          ROLLUPADDISSUBTOTAL(
            ROLLUPGROUP('DimCall'[AgentName], 'DimCall'[Campaign], 'DimCall'[Company]), "IsGrandTotalRowTotal"
          ),
          __DS0FilterTable,
          "CountAgentName", CALCULATE(COUNTA('DimCall'[AgentName]))
        ),
        [IsGrandTotalRowTotal],
        0,
        'DimCall'[AgentName],
        1,
        'DimCall'[Campaign],
        1,
        'DimCall'[Company],
        1
      )
    
    ORDER BY
      [IsGrandTotalRowTotal] DESC,
      'DimCall'[AgentName],
      'DimCall'[Campaign],
      'DimCall'[Company]
    
    
    // SQL Query
    
    SELECT 
    TOP (1000001) [t0].[Campaign],[t0].[Company],
    COUNT_BIG([t0].[AgentName])
     AS [a0]
    FROM 
    (
    (select [$Table].[CallId] as [CallId],
         [$Table].[CallDate] as [CallDate],
        [$Table].[AgentName] as [AgentName],
        [$Table].[Company] as [Company],
         [$Table].[CRMCaseID] as [CRMCaseID]
    from [dbo].[DimCall] as [$Table])
    )
     AS [t0]
    WHERE 
    (
    [t0].[AgentName] = N'Cedric Daughtery'
    )
    
    GROUP BY [t0].[Campaign],[t0].[Company] 
    

     

    clear filter and grouping are sent back to SQL server and only the required result is returned to the report. I hope this answered your question and provided the clarification you need.

     

    I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    ⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡