Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
1 year ago

Formulate Union directly in "Table View"

Good community

I'm trying to load 3 different environments into the same Power BI report where directly in POWER QUERY, I finish each editor of each table I want (Assignments) in this way, getting sort and making sure that the positions and names are all the same in each table.

    #"Columnas reordenadas" = Table.ReorderColumns(#"Columna condicional agregada",{"v_pbi_encargos_id", "articulos_id", "clientes_id", "colores_intensidad_id", "cupon", "descripcion", "encargos_devuelto_id", "encargos_id", "es_encargo", "es_rx", "estado_cabecera", "estados_id", "familias_id", "fecha_ultima_modificacion", "fecha", "garantias_id", "hora", "importe_costo", "importe", "lentes_clasificaciones_id", "lentes_focos_id", "lentes_gamas_color_id", "lentes_indices_id", "lentes_materiales_id", "lentes_tipos_venta_id", "linea_encargo_id", "mis_clasificaciones_id", "mis_colores_detalle_id", "mis_gamas_id", "mis_tratamientos_id", "motivo_devolucion", "procede_presupuesto", "promociones_id", "propiedad_1", "propiedad_2", "propiedad_3", "propiedad_4", "propiedad_5", "propiedad_6", "propiedad_7", "propiedad_8", "tarifas_id", "tiendas_id", "tipo_impositivo", "tipos_encargo_id", "tipos_progresivo_id", "totalmente_pagada", "ultimo_pago", "unidades", "usuarios_id", "ventas_promocion_id", "ventas_promocion_tiendas_id", "vision", "id_usuario", "Momento del Día", "Año", "Clasificación", "Familias", "v_pbi_motivos_garantia_id"}),
    #"Columnas quitadas" = Table.RemoveColumns(#"Columnas reordenadas",{"v_pbi_motivos_garantia_id"})
in
    #"Columnas quitadas"

I go to each table in Power and make sure that all the columns are sorted in the way I've shown above. And indeed in Power Query all columns have a 1:1 ratio

On the other hand, once I load the data and I leave Power Query and go to Desktop to build the charts, in the "Table View" section I create a new table with the data of each one

OrdersAnx = UNION(Orders, 'Encargos_Me') and here everything goes right, all the columns are related and what each column contains is related, but when I am going to add the other table from the other environment that I have brought.
OrdersAnx = UNION(Orders, 'Encargos_Me', 'Encargos_Mo') here at this moment everything is out of balance and the columns are mixed, because each table separately changes the order of columns, but I don't understand why the order of the columns changes

If someone can give me an idea of why this is happening, it would be of great help to me
Thanks a lot

4 Replies

  • Hi Syndicate_Admin ,

    In Power BI, the UNION function combines tables, but it matches columns based on column names, not their order. When you add another table (Encargos_Mo), it causes issues if there are discrepancies in column names or data types across the tables.

     

    Please double check your columns names and data type to see if match.

     

     

    • Syndicate_Admin's avatar
      Syndicate_Admin
      Icon for Administrator rankAdministrator

      The problem lies in the "Close and Apply" that the tables separately change the order of their columns before making UNION().
      Would you know why that could happen?

      • Bibiano_Geraldo's avatar
        Bibiano_Geraldo
        Icon for Super User rankSuper User

        Hi Syndicate_Admin ,

        You're mean that you arranged the order in power query but in power bi its not reflecting, right?

         

        If yes, this is a bug, what you can do is disable load refresh for that table in power query and then close and apply, and back to power query and enable the load refresh and close and apply.

         

        This aproach will load data into power bi with arranged columns.

         

        Note: All calculated columns and measures in disabled load table will be lost