# If then else statement on weekly granularity

#### joslaz

##### Board Regular
Hello everybody!

I have the following two tables:
tblInventory
 Article Value Date (Today) AA1 5000 07.12.2019

tblChanges
 Article Value Date AA1 -500 06.10.2019 AA1 2500 05.11.2019

The tblInventory shows the current inventory level.
The tblChanges shows the different positive and negative bookings for each day.

Know I need a measure, that shows me for the current week the actual inventory from tblInventory and for last week the actual inventory (tblInventory) - Value (tblChanges).

How would you do that?

#### g0lub

##### New Member
Lets rename first sheet as "inventory" like this:
 No article value 1 A1 30 2 A2 25 3 A3 15
In row "value" there is formula " =SUMIF(changes!\$B\$2:\$B\$2000,B2,changes!\$C\$2:\$C\$2000) "

Second sheet named "changes" looks like this:
 No article values date 1 A1 50 2 A1 -20 3 A2 30 4 A3 15 5 A2 -5
Here you can make changes for the articles.

I didn't understand what do you want with dates, can you explain again with an example?

#### macfuller

##### Active Member
How many rows does tblInventory have? e.g. a single weekly value or a daily value? My question is which table to go against - if tblInventory has the actual inventory for each day such that the sum of all daily changes in tblChanges is the difference from the previous row's value in tblInventory, then you can do the measure just against tblInventory (i.e. Today's tbleInventory[Value] - DATEADD(tblInventory[Value], -7, DAY)

And do you have a separate date table?

Since you may have Article AA1 multiple times in tblInventory you can't do a 1:many relationship with tblChanges, so RELATED functions probably won't work.

#### g0lub

##### New Member
tblInventory has 3 columns. Number, name of the article and current value of that article. Which means you know how much sugar, for example, do you have in market.

Why do you need article AA1 multiple times in tblInventory? If you have different types of sugar, let them be different articles.

I didn't understand what is purpose of date in tables. Do you just need to know when did you buy some articles or something more?

1,082,360
Messages
5,364,920
Members
400,815
Latest member
Joaquin Phoenix

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...