Forum Discussion
kimloh_p
6 years agoFrequent Visitor
DAX lookupvalue
Hi Community, I have a single table that contains the following columns [Date], [ID], [Product]. I would like to add [Removed] and [New] calculated columns with the results below and as per logi...
- Anonymous6 years ago
kimloh_p Not sure about granularity of the data but you can use the max date condition in if condition.
Removed_ = VAR _nextMonth = MONTH(NEXTMONTH('Table'[Date])) VAR _maxmonth = MONTH(MAX('Table'[Date])) VAR _table = CALCULATETABLE(VALUES('Table'[ID]),FILTER(ALL('Table'),'Table'[Date].[MonthNo]=_nextMonth)) RETURN IF('Table'[ID] IN _table||'Table'[Date]=MAX('Table'[Date]),BLANK(),"Y")
kimloh_p
6 years agoFrequent Visitor
hi Anonymous
Thank you for the solution, it's so well written, i wouldn't have figured out this method alone.
As for products in the latest month, it should not reflect in the [Removed] column if there is no match in the nextMonth. How do I incorporate this exeptional condition?
Thank you in advance.
Anonymous
6 years agoNot applicable
kimloh_p Not sure about granularity of the data but you can use the max date condition in if condition.
Removed_ =
VAR _nextMonth = MONTH(NEXTMONTH('Table'[Date]))
VAR _maxmonth = MONTH(MAX('Table'[Date]))
VAR _table = CALCULATETABLE(VALUES('Table'[ID]),FILTER(ALL('Table'),'Table'[Date].[MonthNo]=_nextMonth))
RETURN IF('Table'[ID] IN _table||'Table'[Date]=MAX('Table'[Date]),BLANK(),"Y")