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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mmar
Regular Visitor

Filtrar Dinamically DirectQuery

Hola

Tengo dos tablas, Premix_Batch e historiador, y ambas son DirectQueries de una base de datos SQL. Filtrado manual (dentro de PBI) el orderNumber para Premix_Batch obtengo una fila, entre sus columnas hay StartTime y EndTime.

Para obtener datos para Historian utilizo un procedimiento almacenado que acepta como entrada un StartTime y un EndTime (algo como: SELECT * FROM myHistorianTable WHERE LogDateTime BETWEEN StartTime2 And EndTime2). En este momento utilizo valores de solicitud para StartTime2 y EndTime2 (por ejemplo: ENTRE '2020-03-22' Y '2020-03-24').

Por razones de tamaño de datos, debo filtrar los datos entrantes de myHistorianTable en DirectQuery y no puedo importarlos.

Me gustaría poder seleccionar todas las filas en El historiador donde el valor de columna LogDateTime está entre los valores Start_Time y End_Time de la tabla Premix_Batch.

He intentado usar Parameters dentro de DirectQuery pero no puedo modificar el parámetro dinámicamente.

Por ejemplo: "SELECT * FROM myHistorianTable WHERE LogDateTime BETWEEN "Parameter1" And "Parameter2"".

También he intentado usar una consulta (que apunta al primer valor de la columna StartTime1 de la tabla Premix_Batch) dentro de DirectQuery, pero obtengo el error: "Formula.Firewall: Query 'QueryName' (paso 'StepName') hace referencia a otras consultas o pasos y, por lo tanto, puede que no acceda directamente a un origen de datos. Por favor, reconstruya esta combinación de datos."

Debajo de DirectQuery utilizo:

Dejar
Fuente: Sql.Database("VHISTORIAN2017", "Tiempo de ejecución", [Consulta"SELECT * De (-(lf)SELECT * (lf) FROM History (lf)

WHERE History.TagName IN ('SysPerfConfigCPU')-(lf) And wwRetrievalMode ? 'Cyclic'(lf)

And wwCycleCount á 100o(lf) Y wwQualityRule á 'Extendido'(lf)

Y wwVersion á 'Latest'(lf)

Y DateTime > '"& Text.From(StartDate) &"' ?(lf)

Y DateTime <' '"& Text.From(EndDate) &"' ) temp-(lf)LEFT JOIN AnalogTag ON AnalogTag.TagName ?temp. NombreDeEtiqueta(lf)LEFT JOIN EngineeringUnit ON AnalogTag.EUKey á EngineeringUnit.EUKey-(lf)LEFT JOIN QualityMap ON QualityMap.QualityDetail - temp. QualityDetail (lf)

DONDE temp. StartDateTime > '"& Text.From(StartDate) &"' "])
En
Fuente

Tabla Premix_Batch:

Screenshot (307)_LI.jpg

Mesa de Historiador:

Screenshot (308)_LI.jpg

2 REPLIES 2
amitchandak
Super User
Super User

Consulte, si esto puede ayudar

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dynamic-filter-on-direct-query-table-using-Da...

https://www.red-gate.com/simple-talk/sql/bi/power-bi-introduction-working-with-parameters-in-power-b...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hola

Usé desde el principio el artículo de la puerta roja como referencia para usar el parámetro. Pero entonces no puedo cambiar dinámicamente el parámetro que lo establece igual a algunos valores de la tabla Premix_Batch.

¿Hay otra manera o un workaraound para lograr mi objetivo?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.