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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
JUAN_1969
Helper I
Helper I

Importación datos datos servidor sql

Muy buenas.

 

Estoy realizando una conexión a una base de datos sql server, la cual tiene actualmente más de 2 millones de registros y crece diariamente. Necesito, a la hora de trabajar con ella en el editor de Power Query en Power Bi reducir el numero de registros para que sea mas ágil, pero que luego en el escritorio y cuando lo publique disponer del 100 % de los datos.

 

¿Me pueden indicar como se podría hacer?

 

Muchas gracias.

1 ACCEPTED SOLUTION

@JUAN_1969 ,

 

On that row, try 'if dataToggle' not 'If dataToggle' i.e. do not capitalise 'if'.

 

Also, you have misspelled 'toggleStep' in the last line.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

8 REPLIES 8
BA_Pete
Super User
Super User

Hi @JUAN_1969 ,

Create a new blank query called 'dataToggle' or similar. Just apply a single value of 1 to this query.

In your main query with the 2 million rows, under the source/navigation steps, filter your data down to a smaller number of rows that you can work with while developing.

In the M code, add a step that acts as a switch between the filtered version and the full version. It will look something like this:

 

let
  Source = [Your SQL server details],
  Database = [Your database/table navigation],
  dataFilter = Table.SelectRows(Database, Your filter conditions),
  toggleStep = if dataToggle = 1 then dataFilter else Database,
  otherSteps = Continue your transformations here, using toggleStep as the previous step
in
  otherSteps

 

This will give you a filtered dataset to develop with. When you want to publish, just change the '1' in the dataToggle query to another value ('0', or 'n' or anything that isn't '1') and it will unfilter your query ready for publishing.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Muy buenas, gracias por la respuesta.

 

Así me quedó el código M, pero me da error "Exprression.SyntaxError: Se esperaba el token Comma".

 

Es posible que la consulta datoToggle no la haya creado correctamente.

 

 

let

    Origen = Sql.Databases("XXXXX.XX.XXXXXXXX\XXXXX,1111"),

CCCCCC_CCCCCCCC = Origen{[Nombre=" CCCCCC_CCCCCCCC "]}[Datos],

    dbo_DDD_DDDDDDD = CCCCCC_CCCCCCCC {[Schema="dbo",Item=" DDD_DDDDDDD "]}[Data],

#"Filas filtradas" = Table.SelectRows(dbo_ DDD_DDDDDDD, cada [FILA_ID] >= 652345 y [FILA_ID] <= 653345),

toggleStep = If dataToggle = 1 then Filas Filtradas else dbo_DDD_DDDDDD,

otherSteps = Continuar las transformaciones liebre, usando toggleStep como paso anterior,

in

otherSteps

Hi @JUAN_1969 ,

 

You need to correctly reference the different steps in your query, something like this:

 

let
    Origen = Sql.Databases("XXXXX.XX.XXXXXXXX\XXXXX,1111"),
    CCCCCC_CCCCCCCC = Origen{[Name=" CCCCCC_CCCCCCCC "]}[Data],
    dbo_DDD_DDDDDDD = CCCCCC_CCCCCCCC {[Schema="dbo",Item=" DDD_DDDDDDD "]}[Data],
    #"Filas filtradas" = Table.SelectRows(dbo_ DDD_DDDDDDD, each [FILA_ID] >= 652345 and [FILA_ID] <= 653345),
    toggleStep = if dataToggle = 1 then #"Filas filtradas" else dbo_DDD_DDDDDDD,
    nextStep = Any.Function(toggleStep, function arguments),
    anotherStep = Another.Function(nextStep, function arguments),
    ...
    ...
    lastStep = Last.Function(previousStepName, function arguments)
in
    lastStep

 

 

You can see more clearly here how toggleStep references the steps before/after filtering and switches between them to change the table that is carried forward into the following steps.

Ignore everything after toggleStep as these are just example rows showing how each row references the previous one correctly. Power Query will do this for you automatically.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




muy buenas de nuevo

 

creo que el problema lo tengo a la hora de crear la  nueva consulta en blanco llamada 'dataToggle' y aplicar el valor único de 1 a esta consulta, ya que el editor de la consulta donde tengo incluido todos los registros, me marca como error dataToggle.

 

¿Me puedes indicar como crearla?

 

Muchas gracias.

Hi @JUAN_1969 ,

 

Your dataToggle query is literally just this:

let
    Source = 1
in
    Source

 

When you want to change the value, you can just select the query and change the value in the formula bar:

BA_Pete_0-1636546514678.png

 

Your main query should look like this with no transformations:

let
    Origen = Sql.Databases("XXXXX.XX.XXXXXXXX\XXXXX,1111"),
    CCCCCC_CCCCCCCC = Origen{[Name=" CCCCCC_CCCCCCCC "]}[Data],
    dbo_DDD_DDDDDDD = CCCCCC_CCCCCCCC {[Schema="dbo",Item=" DDD_DDDDDDD "]}[Data],
    #"Filas filtradas" = Table.SelectRows(dbo_ DDD_DDDDDDD, each [FILA_ID] >= 652345 and [FILA_ID] <= 653345),
    toggleStep = if dataToggle = 1 then #"Filas filtradas" else dbo_DDD_DDDDDDD
in
    toggleStep

 

Then all of your other transformation steps go after toggleStep.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Buenas nuevamente.

la consulta dataToggle la cree tal como me indicas y en la columna de consultas se visualiza de la siguiente manera. 

 

JUAN_1969_1-1636550898865.png

Pero, en el editor avanzado de la consulta principal, muestra error en la fila 6. No reconoce la expresión dataToggle

 

JUAN_1969_0-1636550672350.png

 

Buenas nuevamente.

la consulta dataToggle la cree tal como me indicas y en la columna de consultas se visualiza de la siguiente manera. 

 

JUAN_1969_1-1636550898865.png

Pero, en el editor avanzado de la consulta principal, muestra error en la fila 6. No reconoce la expresión dataToggle

 

JUAN_1969_0-1636550672350.png

 

@JUAN_1969 ,

 

On that row, try 'if dataToggle' not 'If dataToggle' i.e. do not capitalise 'if'.

 

Also, you have misspelled 'toggleStep' in the last line.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Kudoed Authors