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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Faber13
Helper II
Helper II

Very slow to update power query merge query

I have a table with 100,000 rows and another with 9,000,000 rows and the power query update is very slow, I believe it is the query merge, I took my data source, I do the following treatmentse: 


let

       #"Cabeçalhos Promovidos" = Table.PromoteHeaders(Base_Sheet, [PromoteAllScalars=true]),

    #"Colunas Removidas" = Table.RemoveColumns(#"Cabeçalhos Promovidos",{"Série", "Marcadores", "Vol.", "Peso"}),

    #"Tipo Alterado" = Table.TransformColumnTypes(#"Colunas Removidas",{{"Dt. Emissão", type date}, {"Dt. coleta", type date}, {"Dt. previsão", type date}, {"Dt. entrega", type date}, {"Atraso", Int64.Type}, {"Situação", type text}, {"Coleta", type text}}),

    #"Colunas Removidas1" = Table.RemoveColumns(#"Tipo Alterado",{"Ano/Mês", "Região"}),

    #"Tipo Alterado1" = Table.TransformColumnTypes(#"Colunas Removidas1",{{"Último evento ocorrência", type text}, {"Últ. Ocorrência", type text}, {"Oid Transportadora", type text}, {"Transportadora", type text}, {"UF", type text}, {"Destino", type text}, {"Destinatário", type text}, {"Remetente", type text}, {"Número", type text}, {"Valor", type number}}),

    #"Colunas Removidas5" = Table.RemoveColumns(#"Tipo Alterado1",{"Column40", "Column41", "Ajuste Ecifiência"}),

    #"Consultas Mescladas" = Table.NestedJoin(#"Colunas Removidas5", {"Número"}, #"demandplanning fta_faturamento", {"Nota Fiscal"}, "demandplanning fta_faturamento", JoinKind.LeftOuter),

    #"demandplanning fta_faturamento Expandido1" = Table.ExpandTableColumn(#"Consultas Mescladas", "demandplanning fta_faturamento", {"cd_tipo_de_documento_de_vendas", "cd_pagador", "Nota Fiscal"}, {"demandplanning fta_faturamento.cd_tipo_de_documento_de_vendas", "demandplanning fta_faturamento.cd_pagador", "demandplanning fta_faturamento.Nota Fiscal"}),

    #"Colunas Renomeadas" = Table.RenameColumns(#"demandplanning fta_faturamento Expandido1",{{"okok_fta_faturamento.cd_pagador", "Cód. Cliente"}, {" okok_ fta_faturamento.Nota Fiscal", "Nf Faturamento"}}),

    #"Coluna Condicional Adicionada" = Table.AddColumn(#"Colunas Renomeadas", "Personalizar", each if [Número] = [Nf Faturamento] then "Sim" else "Não"),

    #"Colunas Removidas2" = Table.RemoveColumns(#"Coluna Condicional Adicionada",{"Nf Faturamento"}),

    #"Linhas Filtradas" = Table.SelectRows(#"Colunas Removidas2", each ([Destinatário] <> "Teste),

    #"Colocar Cada Palavra Em Maiúscula" = Table.TransformColumns(#"Linhas Filtradas",{{"Remetente", Text.Proper, type text}, {"Destinatário", Text.Proper, type text}, {"Transportadora", Text.Proper, type text}}),

    #"Consultas Mescladas3" = Table.NestedJoin(#"Colocar Cada Palavra Em Maiúscula", {"Cód. Cliente"}, Dcliente, {"Cód. Cliente"}, "Dcliente", JoinKind.LeftOuter),

    #"Dcliente Expandido" = Table.ExpandTableColumn(#"Consultas Mescladas3", "Dcliente", {"Descrição Rede"}, {"Dcliente.Descrição Rede"}),

    #"Consultas Mescladas1" = Table.NestedJoin(#"Dcliente Expandido", {"Número"}, Devolução, {"Personalizar"}, "Devolução", JoinKind.LeftOuter),

    #"Devolução Expandido" = Table.ExpandTableColumn(#"Consultas Mescladas1", "Devolução", {"Personalizar"}, {"Devolução.Personalizar"}),

    #"Coluna Condicional Adicionada1" = Table.AddColumn(#"Devolução Expandido", "Tem Dev", each if [Devolução.Personalizar] = [Número] then "Sim" else "Não"),

    #"Colunas Removidas3" = Table.RemoveColumns(#"Coluna Condicional Adicionada1",{"Devolução.Personalizar"}),

    #"Tipo Alterado2" = Table.TransformColumnTypes(#"Colunas Removidas3",{{"Tem Dev", type text}}),

    #"Colunas Renomeadas1" = Table.RenameColumns(#"Tipo Alterado2",{{"Personalizar", "tem Fat"}}),

    #"Tipo Alterado3" = Table.TransformColumnTypes(#"Colunas Renomeadas1",{{"tem Fat", type text}, {"Ajuste de Previsão", type date}}),

    #"Valor Substituído" = Table.ReplaceValue(#"Tipo Alterado3",#date(1899, 12, 31),null,Replacer.ReplaceValue,{"Ajuste de Previsão"})

in

    #"Valor Substituído"

1 REPLY 1
lbendlin
Super User
Super User

Usually you want to avoid joins/merges in Power Query as much as possible. Often you can use the Power BI data model instead.

 

If you really must join them you will want to apply your row filters before the join, and also experiment with the join order - big table first or small table first can result in different query plans.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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