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.
Buenas tardes,
Me gustaria saber si existe solucion para la siguiente casuistica.
Quiero extraer datos un SQL, en el que tengo informacion de varias empresas contables. El problema es que cada contabilidad esta guardado en una BBDD diferente, con lo cual no puedo lanzar una consulta de union desde power BI.
Adjunto una captura de pantalla para que vean la situacion.
Se puede hacer de alguna manera la consulta de Union de las distintas contabilidades, para poder tener power bi una unica consulta con los datos de todas las contabilidades.
Gracias de antemano
Solved! Go to Solution.
Finalmente localice una solucion, lo hago de la siguienet manera desde Power Query
let
Origen = Sql.Database("SERVIDOR\INSTANCIA_SQL", "BBDD", [Query="select distinct idempresa from comunidades"]),
idempresas = Table.Column(Origen, "idempresa"),
basesDeDatos = List.Transform(idempresas, each "xxxx_contabilidad_" & Text.From(_)),
CombinarOrigenes = List.Accumulate(
basesDeDatos,
null,
(state, current) => if state = null then
Sql.Database("SERVIDOR\INSTANCIA_SQL", current, [Query="select * from movimientosContables"])
else
Table.Combine({state, Sql.Database("SERVIDOR\INSTANCIA_SQL", current, [Query="select * from movimientosContables"])})
)
in
Origen
Finalmente localice una solucion, lo hago de la siguienet manera desde Power Query
let
Origen = Sql.Database("SERVIDOR\INSTANCIA_SQL", "BBDD", [Query="select distinct idempresa from comunidades"]),
idempresas = Table.Column(Origen, "idempresa"),
basesDeDatos = List.Transform(idempresas, each "xxxx_contabilidad_" & Text.From(_)),
CombinarOrigenes = List.Accumulate(
basesDeDatos,
null,
(state, current) => if state = null then
Sql.Database("SERVIDOR\INSTANCIA_SQL", current, [Query="select * from movimientosContables"])
else
Table.Combine({state, Sql.Database("SERVIDOR\INSTANCIA_SQL", current, [Query="select * from movimientosContables"])})
)
in
Origen
-- create a new database to hold the consolidated data
CREATE DATABASE consolidated_data;
-- create a table in the new database to hold the consolidated data
USE consolidated_data;
CREATE TABLE consolidated_table (
id INT,
company_name VARCHAR(50),
accounting_period VARCHAR(10),
balance DECIMAL(10, 2)
);
-- retrieve data from the first accounting database
USE accounting_db1;
SELECT id, company_name, accounting_period, balance
FROM accounting_table
UNION ALL
-- retrieve data from the second accounting database
USE accounting_db2;
SELECT id, company_name, accounting_period, balance
FROM accounting_table
UNION ALL
-- retrieve data from the third accounting database
USE accounting_db3;
SELECT id, company_name, accounting_period, balance
FROM accounting_table
-- insert the combined data into the consolidated table
INSERT INTO consolidated_table (id, company_name, accounting_period, balance)
SELECT id, company_name, accounting_period, balance
FROM (
-- the UNION ALL statement goes here
) AS subquery;
You can Also do this in Power Query editor
Muchas gracias por propuestas, lo pruebo esta tarde a ver si consigo solucionarlo
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
94 | |
77 | |
65 | |
53 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |