Forum Discussion
dsandberg
Advocate I
9 years agoSet value from existing column/row when adding new column to fact table.
I have a fact table which lists widgets, years, and an attribute of the widget in that year. For example: Widget_ID Year Attribute 1001 2005 1 1001 2006 ...
- 9 years ago
Yes, this worked; I used the MAXX option because my table did have more columns. The column formula turned out to be:
=MAXX(FILTER('Table',('Table'[Widget_ID] = EARLIEST('Table'[Widget_ID]) && 'Table'[Year] = EARLIER('Table'[Year])-1)),[Attribute])
LaurentCouartou
Solution Supplier
9 years agoIs it what you were looking for?
CALCULATE( MAX('Table'[Attribute])
,'Table'[Year] = EARLIER('Table'[Year])- 1
,'Table[Widget_ID] = EARLIER('Table'[Widget_ID])
)Note that, due to the way CALCULATE works, you may get unexpected results if your table has more columns than in your description.
You may prefer something like the following instead:
MAXX( FILTER('Table'
,'Table'[Year] = EARLIER('Table'[Year])- 1
&& 'Table[Widget_ID] = EARLIER('Table'[Widget_ID]
)
, [Attribute]
)- dsandberg9 years ago
Advocate I
Yes, this worked; I used the MAXX option because my table did have more columns. The column formula turned out to be:
=MAXX(FILTER('Table',('Table'[Widget_ID] = EARLIEST('Table'[Widget_ID]) && 'Table'[Year] = EARLIER('Table'[Year])-1)),[Attribute])