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

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.

Reply
saxenaa
Frequent Visitor

Power BI tables loosing calculated columns

I have number of calculated columns in a table which is linked to an excel sheet, every now and then I need to update the excel sheet with new data, 

So I copy the new file to the one linked to BI, but doing so when I refresh the data in BI it looses all calculated columns and resets to what are in excel,

 

this is quite irritating and time consuming to add back the calculated columns, is there a way to handle this?

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @saxenaa,

 

Based on my understanding, you get data from a Excel file name in Power BI desktop, and create some calculated columns. There is a new Excel file which has the same name, you replace the old Excel with this new one, then refresh the data in Power BI desktop, calculated columns disappear, right? 

 

If the new Excel file doesn't have the columns which used in calculated columns, when you refresh the data the error will throw out and the calculated column still exists. If all used columns by calculated columns exist, refresh will get updated data without any error. 

 

In your scenario, when you replace the Excel file, make sure the new Excel file has the same structure as the original one, eg: Sheet name, column names. 

 

Best Regards,
Qiuyun Yu 

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

View solution in original post

3 REPLIES 3
v-qiuyu-msft
Community Support
Community Support

Hi @saxenaa,

 

Based on my understanding, you get data from a Excel file name in Power BI desktop, and create some calculated columns. There is a new Excel file which has the same name, you replace the old Excel with this new one, then refresh the data in Power BI desktop, calculated columns disappear, right? 

 

If the new Excel file doesn't have the columns which used in calculated columns, when you refresh the data the error will throw out and the calculated column still exists. If all used columns by calculated columns exist, refresh will get updated data without any error. 

 

In your scenario, when you replace the Excel file, make sure the new Excel file has the same structure as the original one, eg: Sheet name, column names. 

 

Best Regards,
Qiuyun Yu 

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

Yes that has been the scenario, and I am expecting that excel data can be little different , so is there a way to handle this at powerquery level so that I don't loose the calculated columns in BI

Anonymous
Not applicable

When you create calculated columns in Power BI, those columns are saved into your PBIX file.  These columns are not saved into the excel file.  Power BI does not write back to data sources, it only reads from them.

 

Any calculated column you create is linked to the Query you created, rather than the data source itself.  So if you reconnect the same file, even inside the same project, but it is in a different query then you won't get your calculated columns.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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