Forum Discussion

eliseglines's avatar
eliseglines
Frequent Visitor
5 months ago
Solved

swapping data source excel file?

Hello,

This seems pretty simple but I keep hitting a wall and am not sure how to fix it. I want to keep all my visuals and graphs the same, but need to swap out the excel file as the data source. Unbeknownst to me, there was an extra column "column 1" in the treatments tab of the initial excel file as well as as column "Employer" in the initial excel file as well. I have tried deleting these from the model as well as deleting them from the original file and refreshing the data from there.

I keep receiving the same error message. Is there a way I can keep the visuals and graphs I've created and swap out the data source with a different excel file from here?

 

  • Proposed Solution:

    Replace the Source File

    New Excel file:

    • Must have the same sheet names
    • Must have same column structure

    Apply these steps:

    1. Go to Transform Data
    2. Select the query (for example: Treatments tab)
    3. Click the Source step (on the right under Applied Steps)
    4. Click the (gear icon)
    5. Change the file path to the new Excel file
    6. Click Close & Apply

    If this helps, Mark as Kudos | Mark as Solution| Help Others

6 Replies

  • Proposed Solution:

    Replace the Source File

    New Excel file:

    • Must have the same sheet names
    • Must have same column structure

    Apply these steps:

    1. Go to Transform Data
    2. Select the query (for example: Treatments tab)
    3. Click the Source step (on the right under Applied Steps)
    4. Click the (gear icon)
    5. Change the file path to the new Excel file
    6. Click Close & Apply

    If this helps, Mark as Kudos | Mark as Solution| Help Others

  • Instead of deleting those column sın Power BI, try Refresh data and schema under Refresh option. If you already added delete columns step in Power Query, you would need to delete those steps first.

  • You need to edit the queries that connect to the data and delete any reference that they have to these 'missing' columns. Most likely you'll find them in steps that change data types or delete columns. Can't tell without seeing the M-code.

  • Hi,

     

    der Fehlerbeschreibung nach zu urteilen liegt Dein Problem ja nicht in der Änderung der Datenquelle, sondern an den unterschiedlichen Strukturen der abweichenden Datenquellen. Konkret: Unterschiedliche Anzahl von Spalten, abweichende Spaltennamen. Du benötigst deshalb eine Liste aller zulässigen Spaltennamen und eine der vorhandenen Spaltennamen der aktuellen Datenquelle. 

    Jetzt gibt es wieder 2 Möglicheiten. Die aktuelle Datenquelle enthält entweder alle zulässigen Spaltennamen, dann kannst die alle anderen Spalten, die nicht in der Liste enthalten sind löschen, oder die aktuelle Datenquelle enthält nur einige oder keinen zulässigen Spaltennamen (Beispiel: Umsatz2024 statt Umsatz2025), dann müssen die Spaltennamen vorher angepasst werden. Also Umsatz2024 zu Umsatz2025. 

    Da wir aber die konkrete Situation nicht kennen, kannst Du nur eine pauschale Antwort erhalten.

    Hier ein Beispiel für die dynamische Um- und Rückbennung von Spalten unterschiedlicher Namen und Anzahl:

    let
        Quelle = Excel.CurrentWorkbook(){[Name="tblBestellungen"]}[Content],
    
        Alt = Table.ColumnNames(Quelle),                                                            //Liste der ursprünglichen Spaltennamen
       
        NurPassende = {Character.FromNumber(65)..Character.FromNumber(65 + List.Count(Alt)-1)},     //Liste der alternativen Spaltennamen
        
        PaareNeu = List.Zip({Alt,NurPassende}),                                         //Liste von Paaren Alt/NurPassende für die Umbenennung
        PaareAlt  = List.Zip({NurPassende,Alt}),                                        //Liste von Paaren NurPassende/Alt für die Rückbenennung
        Umbenennen = Table.RenameColumns(Quelle,PaareNeu,MissingField.Ignore),          //Den Spalten die neuen Überschriften verpassen
    
        RenameBack =   Table.RenameColumns(Umbenennen,PaareAlt,MissingField.Ignore)     //UNd jetzt die alten Überschriften wieder verwenden
    in
        RenameBack

     

  • v-aatheeque's avatar
    v-aatheeque
    Community Support

    Hi eliseglines 


    Have you had a chance to look through the responses shared earlier? If anything is still unclear, we’ll be happy to provide additional support.

    • v-aatheeque's avatar
      v-aatheeque
      Community Support

      Hi eliseglines 

      Following up to confirm if the earlier responses addressed your query. If not, please share your questions and we’ll assist further.