Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jesuslogmein
Helper I
Helper I

custom visual write back

Hi I am trying to create a custom visual , my ts script is this:

import powerbi from "powerbi-visuals-api";
import IVisual = powerbi.extensibility.visual.IVisual;
import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions;
import IVisualHost = powerbi.extensibility.visual.IVisualHost;
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions;

export class Visual implements IVisual {
    private target: HTMLElement;
    private host: IVisualHost;

    constructor(options: VisualConstructorOptions) {
        this.target = options.element;
        this.host = options.host;

        // Crear un botón para enviar el filtro "OK"
        this.target.innerHTML = `<button id="btnSendOk">Validacion</button>`;

        const btn = this.target.querySelector("#btnSendOk") as HTMLButtonElement;
        btn.addEventListener("click", () => this.sendOkToModel());
    }

    // Método para enviar el filtro al modelo
    sendOkToModel() {
        const filter = {
            $schema: "http://powerbi.com/product/schema#basic",
            target: {
                table: "tb_llamadas",  // <-- Cambia esto según el nombre real de tu tabla
                column: "transcription_items.transcription_time"  // <-- Cambia esto a la columna deseada
            },
            operator: "In",
            values: ["OK"]
        };

        this.host.applyJsonFilter(
            filter,
            "general",      // objectName
            "merge",        // propertyName (corregido: ahora es un string, no un enum)
            undefined       // identities (opcional)
        );

        console.log("Filtro 'OK' aplicado");
    }

    update(options: VisualUpdateOptions) {
        // Aquí podrías actualizar visualización basada en datos si lo necesitas
    }
}

 

but it fails me, the only thing I want is that the user when he clicks sends OK to the semantic model of the pbi.

help!!!

0 REPLIES 0

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors