Tableau calculated field dates

user3894022

I was trying to do a calculated field and I cannot get it to work right.

First I tried to duplicate what I did in access...

    =DateDiff("d",[90 Days to Exp],[Expiration])        

but that gives me an error

I did some research and found something that gave me valid calculations...

    window_sum(datediff('day',
                lookup(min([90 Days to Exp]), 0),
                min([Expiration])))                     

that only shows 90 days which I already knew

I want to make sure it is doing a count down of days to "Expiration" so I changed it to...

    window_sum(datediff('day',
                lookup(min(NOW()), 0),
                min([Expiration])))          

also tried....

    window_count(datediff('day',
                lookup(min(NOW()), 0),
                min([Expiration])))

still a valid calc but the numbers are way off.... I tried min and max with and without... and I still can't seem to get an accurate count down

Inox

Step back. Instead of giving us random pieces of code, explain what you're trying to achieve (what you expect as a result) and what your db looks like (for instance, what are the fields).

I'll give a solution to what I think you're trying to achieve on what I think you have as database.

I believe you have a database that each entry is a product that have an expiration date ([Expiration]). What I think you're trying to achieve is to know how many days are left until expiration date.

So, if you want to calculate this for each entry in your database, the formula should be:

DATEDIFF('day',NOW(),[Expiration])

It's very straight forward, you're calculating how many days there are between today and expiration date

I have no idea why you're using table calculations in your suggestions, but if this calculations should not be done for each entry (but rather for a collection of entries), then table calculations can be useful, but it's impossible to suggest anything if I don't understand precisely what you want

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Tableau Calculated Field error

Tableau calculated field

MySQL calculated field between dates

Error in Tableau calculated field formula

Second Max in Tableau Calculated Field

Tableau/SQL Calculated Field With Grouping

Tableau multiple charts with calculated field

Tableau Calculated Field using FIXED

Using filtered results as field for calculated field in Tableau

Tableau calculated field summing up the values

Implementing a calculated field within my Tableau Viz

calculated field in tableau dependent on values in column

Tableau Calculated Field COUNTD Single Value

IF part in tableau calculated field is not getting executed

Tableau Calculated Field - across multiple measures

Create a calculated field to count dimension on a condition in Tableau

Tableau: Create a newline between text using a calculated field

Calculated field in tableau to find if the first row is Success or Failure

Get Total Value of Bill Number - Tableau calculated field

Is it possible to count the number of occurrences of a calculated field's result in Tableau?

Regular Expresion in Tableau returns only Null's in Calculated Field

Calculated Field based on an Relation Aggregate with Filter Conditions in Tableau

Tableau calculated field distinct sum of metric base on selected dimensions

Tableau. How to get access to a field value of other record in calculated field?

SQL - Calculated field base on calculated field?

Way to hide blank columns in Table Calc in same sheet as field being calculated? (Tableau)

How to pass each row as an argument to R script from Tableau calculated field

In Tableau how can I create a calculated field that categorizes data based on data across rows?

In tableau, I want to create a calculated field which is based on a filter and outputs an answer also based on a filter