9 Replies Latest reply on Sep 14, 2018 12:36 PM by Shinichiro Murakami

# Check if previous date is the same

Hi,

I am having difficulty in trying to check if previous date (non aggregate dimension) is the same as the next date. I have tried the lookup( ) and previous_value( ) which won't work. For example:

1/8

2/8

3/8

3/8

4/8

4/8

5/8

6/8

On a particular date, I would like to check if it is the same as the previous date? I have an if statement as below:

if "date" = "previous date"

then 0

else 8

end

What would be the best way of doing this?

Thanks

Sophie

• ###### 1. Re: Check if previous date is the same

Hi, Sophie

What's the identity for the row (4/8 has two rows in your sample, there must be identity to distinguish them)?

ZZ

• ###### 2. Re: Check if previous date is the same

In your data , you can easily Identify the duplicates by this

Thanks

Deepak

• ###### 3. Re: Check if previous date is the same

Thanks Deepak and Zhouyi.

Zhouyi, there are other dimensions but I am not sure how I could check whether the date are different.

Deepak solution will work. I could just create a calculate field for that and then use that for my if statement.

Thanks so much,

Sophie

• ###### 4. Re: Check if previous date is the same

Hi Deepak,

The solution only work if there is no other dimensions on the table.

However, if there are, what can I use to differentiate whether the previous date is the same? In below example, if the date are the same then expected hours for the next date would be 0.

For example

Date          Hours Work          Expected Hours

1/8               8                                   8

2/8               8                                   8

3/8               5                                   8

3/8              3                                   0

4/8               4                                   8

4/8               4                                   0

5/8               8                                   8

6/8               8                                   8

Thanks

Sophie

• ###### 5. Re: Check if previous date is the same

Hi again,

Just wanted to add that the Expected Hours is the dimension which I am trying to work out as above.

Thanks

Sophie

• ###### 6. Re: Check if previous date is the same

Assuming you have Row -ID,

Thanks,

Shin

• ###### 7. Re: Check if previous date is the same

Thanks Shinichiro.

The Expected Hours is 8 for each date. The issue is when the Work Hours has been entered more once as example above. Therefore, the total Expected Hours for the day is end up double or triple which is incorrect.

Therefore, regardless of the number of times/rows the Work Hours have been entered, the Expected Hours for the day should only be 8.

From the solution above, you suggested that we added up the Work Hours to compute the Expected Hours. The Expected Hours should always be 8 regardless of how many hours the Work Hours has been entered.

Please let me know if this is still not cleared.

Thanks

Sophie

• ###### 8. Re: Check if previous date is the same

Means this?

Thanks,

Shin

• ###### 9. Re: Check if previous date is the same

Just following up.