Hey, We’re working on implementing drill-down func...
# gooddata-cloud
a
Hey, We’re working on implementing drill-down functionality for the InsightView component. Our current approach is to pass the filters from a parent InsightView to a second InsightView (a table) that uses the same dataset. This setup works fine when the parent InsightView is a KPI. However, when the parent is a chart (like column, bar, or pie), we run into a 400 error from GoodData while trying to drill down — for example, tapping on “July”. What we’re trying to achieve is: when a user taps on a specific data point (e.g., July), we pass that filter to the drill-down table view. Could you please help us understand how to properly capture and pass these filters in this scenario? Are there specific filters or configuration steps we’re missing for chart-based insights? Also open to any suggestions if there’s a better way to structure this drill-down logic. Thanks!
y
Hi Ayush, thanks for reaching out. May you please share a code sample to help us assist you. Also, allow me to ask what version of the SDK you are currently using.
s
@Ayush Kumar - Could you reply back.
a
This is the entry file
DrillDownModal.tsx
This is for the drill down one
Copy code
"@gooddata/sdk-backend-spi": "^10.24.0",
    "@gooddata/sdk-backend-tiger": "^10.24.0",
    "@gooddata/sdk-model": "^10.24.0",
    "@gooddata/sdk-ui": "^10.24.0",
    "@gooddata/sdk-ui-all": "^10.24.0",
    "@gooddata/sdk-ui-ext": "^10.24.0",
r
Hi all, Radek from L2 here - this was passed to me to have a look, I will update you shortly. 🙂
a
Hi @Radek Novacek the approach we are using for drill down is -> I am getting the filters from the parent insight (let's say graph) and then I am passing those filters as positiveAttributeFilters to the drill down insight (table)
Is there any better approach? Where we only need 1 insightview and no manual work, something which can be configured from the dashboard itself
r
Hi @Ayush Kumar, I think your approach should be valid - the issue is most likely the drill complexity difference between what a graph would generate and what a table expects. I'm trying to get some sample code together to point you in the right direction though!
a
Thank you!
r
Hi again @Ayush Kumar, I have something that should be able to help you progress! All you need is a GD app with working authentication, and replacing the "catalog.ts" references with references from your own environment:
Copy code
import { useState } from "react";
import { InsightView } from "@gooddata/sdk-ui-ext";
import { PivotTable } from "@gooddata/sdk-ui-pivot";
import { IDrillEvent } from "@gooddata/sdk-ui";
import { IAttributeFilter, newPositiveAttributeFilter, IFilter } from "@gooddata/sdk-model";
import { OrderUnitPrice, OrderUnitQuantity, CustomerState, ProductBrand, Insights } from "../md/catalog.ts";

export function SimpleDrillExample() {
    const [drillFilter, setDrillFilter] = useState<IFilter | null>(null);
    const [selectedValue, setSelectedValue] = useState<string>("");

    const handleDrill = (drillEvent: IDrillEvent) => {
        // Find the attribute item that was clicked
        const intersection = drillEvent.drillContext?.intersection;
        if (!intersection || intersection.length === 0) return;

        for (const intersectionElement of intersection) {
            const { header } = intersectionElement;

            // Check if this is an attribute (not a measure)
            if (header && "attributeHeaderItem" in header && "attributeHeader" in header) {
                const attributeRef = (header as any).attributeHeader.ref;
                const attributeValue = (header as any).attributeHeaderItem.name;

                console.log(`Drilling on: ${attributeValue}`);

                // Create filter for the clicked value
                const filter: IAttributeFilter = newPositiveAttributeFilter(attributeRef, [attributeValue]);

                setDrillFilter(filter);
                setSelectedValue(attributeValue);
                break;
            }
        }
    };

    const clearDrill = () => {
        setDrillFilter(null);
        setSelectedValue("");
    };

    return (
        <div>
            <h2>Simple Drill-Down Example</h2>
            <p>Click on any slice of the pie chart to filter the table below.</p>

            {selectedValue && (
                <div>
                    <span>Filtered by: {selectedValue}</span>
                    <button onClick={clearDrill}>Clear Filter</button>
                </div>
            )}

            <div style={{ display: "flex" }}>
                <div style={{ flex: 1, height: "400px" }}>
                    <h4>Pie Chart</h4>
                    <InsightView
                        insight={Insights.Pie}
                        drillableItems={[() => true]}
                        onDrill={handleDrill}
                    />
                </div>

                <div style={{ flex: 1, height: "400px" }}>
                    <h4>Results Table</h4>
                    <PivotTable
                        measures={[OrderUnitPrice.Sum, OrderUnitQuantity.Sum]}
                        rows={[CustomerState]}
                        columns={[ProductBrand]}
                        filters={drillFilter ? [drillFilter] : []}
                    />
                </div>
            </div>
        </div>
    );
}
I successfully tested this with my own environment. Please let me know if there's any errors with this, or questions about what the code does, and I will do my best to clarify as well 🙂
a
Copy code
import { OrderUnitPrice, OrderUnitQuantity, CustomerState, ProductBrand, Insights } from "../md/catalog.ts";
We are not going via this catalog approach and instead of using a PivotTable we are using an InsightView
Also how can we create this catalog file?
r
That's done using the catalog export tool - https://www.gooddata.com/docs/gooddata-ui/latest/learn/visualize_data/export_catalog/, it's a really useful way to get references to your existing metrics/attributes/measures!
a
Thank you! Will look into this
s
Hey @Radek Novacek What ideally, we would assume GD to help us with here is:- 1. Underlying Data exists for each KPI, Chart Type. 2. GD to dynamically generate the underlying data with the capability to pick and choose the columns to display. 3. We render that info. and open it in a dialog box in our Front-end. 4. Using SDK export helpers- The data if requested gets exported to the user's Local Directory for Validation and review. However- The Current documentation is unclear on whether this exact way is possible or what is the right way to do it. There is too much guess work at our end. In this method in the trailing Slack thread • We need to create a separate insight view for each KPI / Chart which we want to drilldown. Which is Double work of creating KPi + Creating Drill Down insight. I hope you understand my problem statement!
However- There is a limitation in the amount of communication that can happen over a slack/Message mode. We are still in Alpha phase of Go-Live and unable to golive without the specific help here. [We are delayed by 2 months internally] We would highly appreciate a Meeting between yourself and our team! 1. Different Approaches of Implementing DrillDown. 2. Varying Currency of the child workspace[Parametric Currency Parameter]. Why we need your help here:- 1. The workaround for Drilldown which we discussed over Slack was not a documented approach but an implied approach a. There is a risk that the approach might not be the best. 2. Without Drill Down[Underlying Data]- Our end Customers would be unable to trust the data in our dashboard a. W/O- It, we will be unable to scale from the current 50 Workspaces i. To the projected count of 300 workspace. b. Ideally-- As per our initial Launch Plan shared with Constantin[AE of GD] i. We should have launched to all merchants by now which would have meant 320 workspaces at least being consumed by us. We are unable to debug the best way to have parametric currency of the Child Workspace @Radek Novacek
p
Hello Swapnil, I will connect with you directly. Thank you
🙏 2