Forum Discussion

PeterM's avatar
PeterM
New Member
8 years ago
Solved

compare last week value and Current week for Inventory

Hello,   I am trying to Display last week result and current week result Location wise to compare the Inventory. For this, I have created two tables 1.LastweekData and 2.CurrentweekData table.   ...
  • TomMartens's avatar
    8 years ago

    Hey,

     

    I would create a calculated column in your currentweek table like so:

    LastWeekValue = 
    LOOKUPVALUE(
      'LastweekData'[Value]
      ,'LastweekData'[Locationid], 'CurrentweekData'[Locationid]
    ,'LastweekData'[ITEMID], 'CurrentweekData'[ITEMID] )

    I assume that the column ITEMID is not something like a product id but uniquely identifies a row in each table, meaning it's a technical column and not a business related column. In this case you have to delete the line that contains the reference to ITEMID in the above statement.

    Here is a more information about the LOOKUPVALUE function:

    https://msdn.microsoft.com/de-de/library/gg492170(v=sql.120).aspx

     

    Please be aware that you may overlook values that are not present in the CurrentweekData table, but have values in your LastweekData table.

     

    You may consider a little remodelling of your data model, by creating a Location Table containing the columns LocationID and LocationName with the unique values of both tables and then create a relationship with the Currentweek and Lastweek table and then just use the Location information from this table in your reports.

     

    Hopefully this is what you are looking for

     

    Regards

    Tom