ovess
ovess

Reputation: 13

Calculate product rate of previous day in tableau

I have a sample dataset:

DATE:  11-01-2015,   12-01-2015,  13-01-2015            
SALE:  $120,                $0 ,         $100     

In tableau I want if Today's sale is 0 as given above for 12-0-2015 then previous day sale should be considered as today's sale.

Can anyone help?

Upvotes: 1

Views: 208

Answers (2)

Armin
Armin

Reputation: 363

Create a calculated field with this formula:

IF SUM([Sale])=0
THEN LOOKUP(SUM([Sale]),-1)
ELSE SUM([Sale])
END

And compute using Date.

Upvotes: 1

Alex Blakemore
Alex Blakemore

Reputation: 11921

IF FIRST() <> 0 AND SUM([Sale])=0 THEN LOOKUP(SUM([Sale]), -1)
ELSE SUM([Sale]) END

Setting Compute Using to Date

Checking First() in the condition handles the case when the first day had zero sales

Upvotes: 0

Related Questions