Forum Discussion
Time Intelligence Functions Not Working After Changing Database Source in Advanced Editor
- 11 months ago
hi, fayzy100
when i had multiple data sources in my project i used parameters for the database name, i never faced any issue, we used to change dadtasource dynamically from parameters without touching the source code. when you change the datasource powerbi will change the internal column ids, even though your columns have similar names their ordering ids will be different, can you confirm which data source you were using in dev and what is in prod?
Hi fayzy100
Yes as per my understanding, what you’re describing is a known and recurring behavior in Power BI, particularly when the data source connection is manually altered through the Advanced Editor. Even though the schema and table names remain identical, the internal lineage IDs (the hidden identifiers Power BI uses to map model relationships and metadata) can break silently during this process. These lineage IDs are crucial for DAX Time Intelligence functions, because Power BI relies on them to understand which date column is being used for filtering and which tables are linked to it.
When you change the connection string directly in the M code via the Advanced Editor, Power BI essentially treats it as a new query instance, even if the table name and structure are identical. This disrupts the lineage between your Date table and related fact tables. As a result, functions like TOTALYTD, SAMEPERIODLASTYEAR, or DATESYTD lose the internal reference that tells them which column represents “Date,” leading to blank or incorrect results.
Your observations and troubleshooting steps are spot-on. The most reliable and supported way to change the data source — while preserving lineage — is to use File → Options and Settings → Data Source Settings → Change Source.... This approach updates the connection at the metadata level without regenerating lineage IDs, so the semantic model and relationships remain intact. If you must modify the M query directly, a workaround is to copy the new connection details (server/database names) into the existing source step without deleting or reloading the query, ensuring Power BI doesn’t treat it as a new object.