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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
tarun89engg
Helper I
Helper I

cambiar el origen de datos a sql server Power bi se bloquea durante la creación de conexión en el modelo

Hola a todos

anteriormente en powerbi hay un origen de Excel como datos ahora me gustaría cambiar este origen a Sql Server con consulta.

He importado una nueva fuente de datos desde sql Server y obtengo el código M y reemplazo este código M a mi origen de datos de Excel anterior.

Puedo ver en el editor de consultas de energía que obtiene nuevos datos de sql server sin ningún problema.

cuando cierro y aplico el editior de consulta de poder que crahses en durante la creación de conexión en el modelo con el siguiente mensaje de error

No se pudieron guardar las modificaciones en el servidor. Error devuelto: 'Se ha producido un error inesperado (archivo 'tmtransaction.cpp', línea 5190, función 'TMTransaction::InferTypesForCalcPartition').
'.

Aquí está la captura de pantalla.

2.png

Lo que me gustaría lograr es con la fuente de datos de Excel he creado Mesaure y en lugar de crear todo este Mesarue de nuevo con el nuevo nombre de tabla me gustaría reemplazar los datos de origen.

Gracias por tu tiempo.

Regads,

Toma

8 REPLIES 8
v-yiruan-msft
Community Support
Community Support

Hola @tarun89engg ,

¿Se ha resuelto si el problema? En caso afirmativo, ¿podría compartir la solución si es conveniente y marcarla como Respondida? Ayudará a otros miembros de la comunidad a encontrar la solución fácilmente si se enfrentan al problema similar con usted. Gracias.

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@yingyinr

No estoy seguro de dónde estaba el problema.

He creado ese archivo pbix con la versión antigua powerbi (probablemente alguna versión de 2018).

que a principios de 2020 he instalado una nueva versión de Powerbi y utilizando el mismo powerfile creado en 2018.

He creado un nuevo pbix completo con una nueva versión de 2020 Pwerbi con los mismos datos y el mismo M-Code y funciona en ese archivo. Puedo volver a la fuente de Excel y sorce de base de datos con dos diferentes códigoS M y funciona perfectamente.

crear un nuevo archivo comlete funciona para mí.

saludos

Toma

Hola @tarun89engg ,

Es muy agradable saber que su problema se ha resuelto mediante la creación de un nuevo archivo. Gracias por compartir su solución aquí. ¿Podrías marcar tu última publicación como Respondida? Entonces los miembros de la comunidad pueden encontrarlo rápidamente si se enfrentan al problema similar con usted. Gracias.

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yiruan-msft
Community Support
Community Support

Hola @tarun89engg ,

Compruebe si todas las estructuras de tabla y los nombres de campo son los mismos con los de origen de Excel. ¿Podría proporcionar algunas capturas de pantalla de las tablas en código fuente SQL y Excel? Por favor, comparta los códigos en advanced Editor como sugiere @mwegener o su archivo pbix de muestra si es conveniente. Gracias.

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@yingyinr

@mwegener

Aquí está el código M para la fuente de Excel

let
    Source = Excel.Workbook(File.Contents("C:\Users\HEL_TPatel\OneDrive - Magna\Desktop\SPS_bvo2_new.xlsx"), null, true),
    Tabelle1_Sheet = Source{[Item="Table9",Kind="Table"]}[Data],
    #"Changed Type with Locale" = Table.TransformColumnTypes(Tabelle1_Sheet, {{"DateTime", type datetime}}, "bn-IN"),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type with Locale"," _","__",Replacer.ReplaceText,{"txtName"}),
    #"Filtered Rows2" = Table.SelectRows(#"Replaced Value", each ([SPS_Bereich] = "helpebvo2")),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Filtered Rows2", "txtName", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"txtName.1", "txtName.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"txtName.1", type text}, {"txtName.2", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"txtName.2", "Message"}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns",{"txtCame"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns1",{{"txtName.1", "Machine"}}),
    #"Grouped Rows" = Table.Group(#"Renamed Columns1", {"DateTime"}, {{"TimeDiff", each List.Max([TimeDiff]), type number}, {"Details", each _, type table [DWH_ID=number, SPS_Bereich=text, ID=number, DateTime=datetime, Classname=text, Machine=text, Message=text, TimeDiff=number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Top", each Table.Max ([Details], "TimeDiff")),
    #"Removed Columns2" = Table.RemoveColumns(#"Added Custom",{"Details"}),
    #"Expanded Top" = Table.ExpandRecordColumn(#"Removed Columns2", "Top", {"ID", "Machine", "Message"}, {"ID", "Machine", "Message"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Top", each [TimeDiff] >= 10),
    #"Added Custom1" = Table.AddColumn(#"Filtered Rows", "Custom", each [DateTime]+#duration(0,0,0,[TimeDiff])),
    #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom", type datetime}}),
    #"Changed Type5" = Table.TransformColumnTypes(#"Changed Type2",{{"ID", Int64.Type}}),
    #"Renamed Columns3" = Table.RenameColumns(#"Changed Type5",{{"Custom", "datewithaddedsecond"}}),
    #"Renamed Columns5" = Table.RenameColumns(#"Renamed Columns3",{{"ID", "Index"}}),
    #"Renamed Columns6" = Table.RenameColumns(#"Renamed Columns5",{{"DateTime", "Start Date"}, {"datewithaddedsecond", "End Date"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns6",{{"TimeDiff", Int64.Type}}),
    #"Inserted Date" = Table.AddColumn(#"Changed Type", "Date", each Date.From([Start Date]), type date),
    #"Filtered Rows1" = Table.SelectRows(#"Inserted Date", each ([Date] <> #date(2019, 1, 3))),
    #"Changed Type3" = Table.TransformColumnTypes(#"Filtered Rows1",{{"Machine", type text}, {"Message", type text}}),
    #"Renamed Columns2" = Table.RenameColumns(#"Changed Type3",{{"Index", "Index"}, {"Start Date", "Start Date"}})
in
    #"Renamed Columns2"

Aquí está el código M para la nueva base de datos de SQL Server

let
    Source = Sql.Database("HELMSSQL04\INSTANZ1", "Stoerdaten", [Query="SELECT TOP 200 sto.[DWH_ID]#(lf)      ,sto.[SPS_Bereich]#(lf)     ,FORMAT(sto.[DateTime], 'dd-MM-yyyy HH:mm') as [Start Date]#(lf)          ,sto.[txtName]#(lf)       ,sto.[TimeDiff]#(lf)  FROM [Stoerdaten].[sta].[Stoerungen]  sto#(lf)  join #(lf)  [IgnitionServer].[dbo].[scheduled_events_ISTProduction] cal on #(lf)  DateTime #(lf)  between cal.start_date and cal.end_date #(lf)  where sto.Classname = 'Alarm' and sto.TimeDiff >60#(lf)     and cal.typ=1 order by id desc #(lf)"]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([SPS_Bereich] = "helpebvo2")),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Filtered Rows", {{"Start Date", type datetime}}, "en-IN"),
    Index = Table.RenameColumns(#"Changed Type with Locale",{{"DWH_ID", "Index"}}),
    #"End Date column" = Table.AddColumn(Index, "End Date", each [Start Date]+#duration(0,0,0,[TimeDiff])),
    #"End Date change to Date Type" = Table.TransformColumnTypes(#"End Date column",{{"End Date", type datetime}}),
    #"Grouped Rows" = Table.Group(#"End Date change to Date Type", {"Start Date"}, {{"TimeDiff", each List.Max([TimeDiff]), type number}, {"Details", each _, type table [Index=number, SPS_Bereich=text, Start Date=datetime, txtName=text, TimeDiff=number, End Date=datetime]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Top", each Table.Max ([Details], "TimeDiff")),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Details"}),
    #"Expanded Top" = Table.ExpandRecordColumn(#"Removed Columns", "Top", {"Index", "SPS_Bereich", "txtName", "End Date"}, {"Index", "SPS_Bereich", "txtName", "End Date"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded Top",{{"Index", Int64.Type}, {"SPS_Bereich", type text}, {"txtName", type text}, {"End Date", type datetime}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Changed Type",{"Index", "SPS_Bereich", "Start Date", "TimeDiff", "End Date", "txtName"}),
    #"Replaced Value" = Table.ReplaceValue(#"Reordered Columns"," _","__",Replacer.ReplaceText,{"txtName"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value", "txtName", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"txtName.1", "txtName.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"txtName.1", type text}, {"txtName.2", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"txtName.1", "Machine"}, {"txtName.2", "Message"}}),
    #"Inserted Date" = Table.AddColumn(#"Renamed Columns", "Date", each Date.From([Start Date]), type date),
    #"Filtered Rows1" = Table.SelectRows(#"Inserted Date", each ([End Date] <> #datetime(2020, 5, 28, 19, 47, 37)))
in
    #"Filtered Rows1"

Solo hay una columna nueva en la base de datos de SQL Server que se SPS_Bereich que no sea que todos los nombres de columna sean los mismos al final del código M.

orden de columna es diffrenet en Nuevo M-Code, pero no creo que cause problema.

Aquí está la captura de pantalla que explica qué tabla tiene Excel y sql server datasource.

2020-07-12_10-20-08.png

Me gustaría reemplazar el código M de ErrorLogs con SQL_ErrorLogs.

Aquí está el enlace para el archivo .pbix

Archivo .pbix

Gracias por buscar en este problema.

Regads,

Toma

Hola @tarun89engg ,

Dado que no hay credenciales de orígenes de datos relevantes, es difícil averiguar la causa del problema. Por favor, intente crear una consulta en blanco primero por sí mismo, agregue los siguientes códigos aplicados con información de origen en el Editor avanzado. y luego haga clic en el botón"Aplicar"para ver si se puede guardar normalmente. Si se puede guardar correctamente, continúe agregando los siguientes códigos de paso aplicados y repita los pasos anteriores. Realice la solución de problemas paso a paso para comprobar qué paso causó el error guardar correctamente.

let
    Source = Sql.Database("HELMSSQL04\INSTANZ1", "Stoerdaten", [Query="SELECT TOP 200 sto.[DWH_ID]#(lf)      ,sto.[SPS_Bereich]#(lf)     ,FORMAT(sto.[DateTime], 'dd-MM-yyyy HH:mm') as [Start Date]#(lf)          ,sto.[txtName]#(lf)       ,sto.[TimeDiff]#(lf)  FROM [Stoerdaten].[sta].[Stoerungen]  sto#(lf)  join #(lf)  [IgnitionServer].[dbo].[scheduled_events_ISTProduction] cal on #(lf)  DateTime #(lf)  between cal.start_date and cal.end_date #(lf)  where sto.Classname = 'Alarm' and sto.TimeDiff >60#(lf)     and cal.typ=1 order by id desc #(lf)"]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([SPS_Bereich] = "helpebvo2")),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Filtered Rows", {{"Start Date", type datetime}}, "en-IN")
in
#"Changed Type with Locale"

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hola @tarun89engg ,

Lo siento. No puedo resolver este problema de forma remota.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Hola @tarun89engg ,

puede compartir su código M?

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors