Forum Discussion

guiferviz's avatar
guiferviz
Frequent Visitor
8 years ago

Force a Custom Visual to make a Top N query

Hi all,

 

I have a Direct Query report similar to the next one:

When I refresh the report the SQL profiler shows the query that the filter send to the server:

SELECT 
TOP (1002) [t0].[Name]
FROM 
(
(select [$Table].[Id] as [Id],
    [$Table].[Name] as [Name],
    [$Table].[Gender] as [Gender],
    [$Table].[Count] as [Count]
from [dbo].[Name] as [$Table])
)
 AS [t0]
GROUP BY [t0].[Name]
ORDER BY [t0].[Name]
ASC
 

With this example (name filter) there is no problem, it works perfectly, but I have some clients that need a Text Filter over a column with very large texts (more than 10MB of text in some rows). A Top 1002 with roughly 10MB of text per row leaves the visual without memory. A top 1 or even a top 0 would be enough because the visual is a Text Filter an does not need any values.

 

I have tried to create a custom visual similar to the Text Filter that I have used in the above example and I tried to limit the number of rows it loads using the property "dataReductionAlgorithm" in the capabilities.json but the SQL query remains to be the same. I have also tested the “dataVolume” property, but I think that it did nothing. I'm saying I think because for some properties in the capabilities.json the only documentation that I have found is in the JSON schema (https://github.com/Microsoft/PowerBI-visuals-tools/blob/master/templates/visuals/.api/v1.10.0/schema.capabilities.json) and it is not very detailed. Below there is a fragment of the capabilities.json file I have used.

 

        "categorical": {
          "dataVolume": 1,
          "categories": {
            "for": {
              "in": "field"
            },
            "dataReductionAlgorithm": {
              "top": {
                "count": 1
              }
            }
          }
        }

 So, my question is: Is there a way of limiting the Top 1002 query made by the filter?