Forum Discussion

Momzi's avatar
Momzi
New Member
1 year ago
Solved

Power BI Measures Automatically Change Column References After Table Load

 

After loading new data into Power BI that has a different structure, the measures automatically change their column references even though, after the transformations in Power Query, the final structure aligns with the original model. This results in broken measures that reference incorrect columns after the data is loaded, despite the correct columns existing in the final dataset.

This behavior is unexpected because Power BI should maintain the original column references in measures after the data is fully loaded and transformed.


Steps to Reproduce:

  1. Start with an existing Power BI model that has a table (e.g., xtable) and a DAX measure that references a specific column (e.g., SUM(xtable[value])).
  2. Load a new dataset into Power Query that has a different structure (e.g., additional columns, renamed columns, etc.).
  3. Perform necessary transformations in Power Query to align the new data with the original structure (e.g., renaming columns, removing unnecessary columns).
  4. After applying the transformations, load the data back into Power BI.
  5. After loading, check the existing measure, which should still reference xtable[value], but now references an incorrect column, such as xtable[month].

Expected Behavior:

  • The measures should retain their original column references (e.g., xtable[value]) after the table is loaded and transformations are applied, as long as those columns still exist in the final dataset.
  • Power BI should not automatically change measures to reference different columns when the intended columns are still present in the model.

Actual Behavior:

  • After applying the Power Query transformations and loading the data, Power BI changes the measure's column reference from xtable[value] to an incorrect column, such as xtable[month], even though xtable[value] still exists in the final dataset.
  • This leads to broken measures, requiring manual intervention to restore the original column references.
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi,FreemanZ ,thanks for your concern about this issue.

    Your answer is excellent!
    And I would like to share some additional solutions below.

    Hello,Momzi . I am glad to help you.
    I hope my suggestions below are helpful.
    Unfortunately, at the moment for power bi when the data model is changed (e.g. name, table structure modified or new table added), the references to calculated columns and metrics may not all be automatically updated to the correct columns or tables. This is an unavoidable problem.
    In this case, the best thing to do is to manually check and modify the metrics that are causing the problem, or recreate the metrics or calculated columns if necessary.
    You can pay attention to naming conventions when creating calculation columns/measures:
    1. When creating a calculated column, carry the table name with you.

    calclulate column ='Table'[column 1]


    2. When creating a measure, try not to carry the name of the table

    measure = MAX([column 1])

    By following a naming convention, the risk of referencing errors can be somewhat minimized. Additionally, maintaining consistent naming conventions and regularly checking the metrics and calculated columns in your model can help ensure the stability and accuracy of your data model.

    I hope you find the following related links helpful.

    URL:Automate the best practice of proper column & measure references

    Similarly, you can use external tools to assist you in checking changes in the data model.
    Using the Tabular Editor is a good option.
    It not only allows you to check the structure of a table model with a set of metrics and calculated columns, but also helps you to optimize the whole model (calculating how efficiently they work and how much memory they take up).

    URL:
    https://github.com/otykier/TabularEditor/releases
    https://www.sqlbi.com/tools/vertipaq-analyzer/
    Solved: Best Practice: Data has changed column names, how ... - Microsoft Fabric Community
     


    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Carson Jian,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • hi Momzi ,

     

    the measure reference follows the query(table) and column, not the name of a query(table) and the name of a column.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,FreemanZ ,thanks for your concern about this issue.

    Your answer is excellent!
    And I would like to share some additional solutions below.

    Hello,Momzi . I am glad to help you.
    I hope my suggestions below are helpful.
    Unfortunately, at the moment for power bi when the data model is changed (e.g. name, table structure modified or new table added), the references to calculated columns and metrics may not all be automatically updated to the correct columns or tables. This is an unavoidable problem.
    In this case, the best thing to do is to manually check and modify the metrics that are causing the problem, or recreate the metrics or calculated columns if necessary.
    You can pay attention to naming conventions when creating calculation columns/measures:
    1. When creating a calculated column, carry the table name with you.

    calclulate column ='Table'[column 1]


    2. When creating a measure, try not to carry the name of the table

    measure = MAX([column 1])

    By following a naming convention, the risk of referencing errors can be somewhat minimized. Additionally, maintaining consistent naming conventions and regularly checking the metrics and calculated columns in your model can help ensure the stability and accuracy of your data model.

    I hope you find the following related links helpful.

    URL:Automate the best practice of proper column & measure references

    Similarly, you can use external tools to assist you in checking changes in the data model.
    Using the Tabular Editor is a good option.
    It not only allows you to check the structure of a table model with a set of metrics and calculated columns, but also helps you to optimize the whole model (calculating how efficiently they work and how much memory they take up).

    URL:
    https://github.com/otykier/TabularEditor/releases
    https://www.sqlbi.com/tools/vertipaq-analyzer/
    Solved: Best Practice: Data has changed column names, how ... - Microsoft Fabric Community
     


    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Carson Jian,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.