sql-bi / DaxTemplate

Tabular and DAX template engine
MIT License
17 stars 4 forks source link

RestoreAffectedRelationships - column does not exist in the collection #10

Closed albertospelta closed 1 year ago

albertospelta commented 2 years ago

The exception occurs here on line 226

https://github.com/sql-bi/DaxTemplate/blob/fbc844b9cc154701cf1fc0d03d3615d260e97825/Dax.Template/Tables/TableTemplateBase.cs#L217-L229

Message: An object with name 'Date' does not exist in the collection. (Parameter 'name') Exception type: System.ArgumentException

System.ArgumentException:
   at Microsoft.AnalysisServices.Tabular.NamedMetadataObjectCollection`2.get_Item (Microsoft.AnalysisServices.Tabular, Version=19.36.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91)
   at Dax.Template.Tables.TableTemplateBase.<RestoreAffectedRelationships>g__GetColumn|27_0 (Dax.Template, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null)
   at Dax.Template.Tables.TableTemplateBase.RestoreAffectedRelationships (Dax.Template, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null)
   at Dax.Template.Tables.TableTemplateBase.ApplyTemplate (Dax.Template, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null)
   at Dax.Template.Tables.Dates.BaseDateTemplate`1.ApplyTemplate (Dax.Template, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null)
   at Dax.Template.Tables.TableTemplateBase.ApplyTemplate (Dax.Template, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null)
   at Dax.Template.Engine.CreateDateTable (Dax.Template, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null)
   at Dax.Template.Engine+<>c__DisplayClass5_0.<ApplyTemplates>g__ApplyCustomDateTable|3 (Dax.Template, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null)
   at Dax.Template.Engine+<>c__DisplayClass5_0.<ApplyTemplates>b__0 (Dax.Template, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null)
   at System.Collections.Generic.List`1.ForEach (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Dax.Template.Engine.ApplyTemplates (Dax.Template, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null)
marcosqlbi commented 2 years ago

We need a file to reproduce the issue. Looking at the code, it could be that a column used by a relationship with Date has been translated and it does not correspond to the name found before, but it does not make much sense, we tested this scenario and it should work. Could it be in case the reference table is not used? But it doesn't seem the case for Bravo, which always uses the hidden template table for the Date.

albertospelta commented 2 years ago

We received a feedback on this error Bravo/issues/349

marcosqlbi commented 2 years ago

Should be fixed by this commit: https://github.com/sql-bi/DaxTemplate/commit/813a46e9793c4b49e503c7e2ff0110f7c35637b7

albertospelta commented 2 years ago

Reopened due to this issue https://github.com/sql-bi/Bravo/issues/406