Forum Discussion

Hannag82's avatar
Hannag82
New Member
3 years ago
Solved

%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_Deckler's avatar
    Greg_Deckler
    Community 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)
  • Anonymous's avatar
    Anonymous
    Not 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