Forum Discussion
%change in demand
I have a dataset with demand qty per SKU per month for 2022-2026. Once a month I receive updated demand - I would like to calculate the change in current demand from last month demand. I would appreciate advise on this. I have appended two demand queries (for Aug. 22 & jul. 22) into one query and I have column Table name to distuingish between the demand dataset
Hannag82 This would be easiest if you had something like a Date column (8/1/2022, 7/1/2022). Then you could do something like this:
% Change Column = VAr __Date = [Date] VAR __CurrentQty = [Qty] VAR __SKU = [SKU] VAR __LastMonth = MAXX(FILTER('Table',[SKU] = __SKU && [Date] < __Date),[Date]) VAR __LastMonthQty = MAXX(FILTER('Table',[SKU] = __SKU && [Date] = __LastMonth),[Qty]) VAR __Diff = __CurrentQty - __LastMonthQty RETURN DIVIDE(__Diff, __LastMonthQty, 0)
2 Replies
- Greg_DecklerCommunity Champion
Hannag82 This would be easiest if you had something like a Date column (8/1/2022, 7/1/2022). Then you could do something like this:
% Change Column = VAr __Date = [Date] VAR __CurrentQty = [Qty] VAR __SKU = [SKU] VAR __LastMonth = MAXX(FILTER('Table',[SKU] = __SKU && [Date] < __Date),[Date]) VAR __LastMonthQty = MAXX(FILTER('Table',[SKU] = __SKU && [Date] = __LastMonth),[Qty]) VAR __Diff = __CurrentQty - __LastMonthQty RETURN DIVIDE(__Diff, __LastMonthQty, 0) - AnonymousNot applicable
Hi Hannag82 ,
Could you please tell me has your problem been solved?
If so, please mark the reply as a solution and more people will benefit from it.
Best Regards,
Stephen Tao