I have a series of parameters in Tableau corresponding to every month in the coming years. The parameter names are all in the format Name - YYYY-MM-DD where YYYY-MM-DD is the corresponding beginning of the month. I would like to reference the parameter using the current month value (e.g. 2017-11-01).
How can I reference a parameter using something like the following:
["Name "+DATEFUNCTION()]
where DATEFUNCTION() will create the date in the appropriate format. However, this clearly does not work.
Referencing parameter name dynamically is not possible.
You can either try to implement your logic of pulling data out of parameters as a single calculated field or use a secondary datasource containing Date,Value,DummyLinkToPrimary fields and filter it on date.
Related
I am trying to convert a field that contains strings such as 202008, 202108 to a date field. I have tried the date() function, clicking on the measure and converting it to a date. I have also tried DATE(LEFT([Month],4)+"-"+RIGHT([Month],2)+"-01") but that will only return the year.
Using Tableau Desktop 2021.1, when I change the data type from String to Date, Tableau translates the strings to 8/1/2020 and 8/1/2021. If you are using an earlier version of Desktop, it is possible that this functionality is not present.
However, if changing the data type isn't working for you, the calculated field code you provided should actually work, you just need to change the date part from Year to Month/Day/Year using the Custom date part option.
I have created daily dashboard which shows the data for single date selected from DATE PARAMETER (with ALL value). Which is OK for me that I can see the data for any date I want.
But the problem is when I open my dashboard it is showing data for date which I selected in date parameter while publishing the Dashboard to Server/Online and Instead of that I want set it default to Yesterday.
i.e. when I open my dashboard first time it should show yesterday's data and also there should option to change date as well to see another date data.
Can we achieve this using DATE PARAMETER (with ALL values)? If it is not possible then is there any other way?
Please Help!
Use a relative date filter instead of a parameter. Just be sure to save and publish the workbook with Yesterday as the relative date value.
1, Create a calculation field d_yesterday, formula is TODAY()-1
2, Create a parameter, data type is Date, value when workbook opens set to d_yesterday
3, use the Date parameter in other calculations fields, or insert parameter into custom SQL query.
I'm trying to create a calculated field in a jasper domain which is a value of field is Datenum. I need to convert that datenum into a date format (1/1/16 or like this) while creating the calculated field.
I have tried by only changing the datatype from number to date. but it only gives something like this(1/1/70). I have attached screenshots below.
Are there any way to use this field as date field.
Conversion
First, you are not using any function to tell Jasper that you need a date. You have only set the data type to date. Since Java date began counting at 01.01.1970 this is the date you get.
The calculated field doesn't know how to interpret your data in the format 20160101. It is possible to use a DomEL function called date in the expression which interprets a date in ANSI format:
date('2016-01-01')
Nonetheless the format of the field SUBMITDATENUM is different. The date function will not be able to interpret this. Unfortunately I am not aware if it is possible to provide a format in which the data is interpreted.
Datebase options
If you can change the format of the table structure, simply add another field or change the data format of the field (if feasible). Otherwise, you could add a database view which converts the field into a "real" date field.
This is the solution I would go for.
More options
There might be a possibility in version 6 with Groovy since it can be used inline:
<field id="e.groovyEval" dataSetExpression="groovy('(5.0/6).toString()')" type="java.lang.String" />
So with the correct Groovy function (which I haven't used yet - I don't know if variables can be inserted) this could help:
<field id="e.groovyDate" dataSetExpression="groovy('Date.parse(\'yyyyMMdd\', ASASMARTLAYER_PHWORDERSPAN.SUBMITDATENUM)')" type="java.lang.Date" />
I have this list of date. i need to select only any future date from the list without csv. how can i do this?
Image of list of date
Option 1: HTML Link Parser - see Poll Example
Option 2: Combination of XPath Extractor and __Random() function
You can use ${__time(dd,)} to get current date. This date will be in String format. Lets store this to variable name date
Convert this date in number with java script function parseInt in BSF pre processor. Lets store this to variable name date_int
Now with random function ${__Random(${date_int},30,)}, you will get random number between current date and 30th of the month.
Use this random number for selecting index of your date list.
code is here
This is working here.
I have putted the myDay,myMonth,myYear variables as parameter.
I have a decimal date field (TDDATR) that is in the YYYYMMDD format.
I would like to create a field that is TDDATR + 30 days but I am unable to.
Using 'Define Results Field' I have tried a few things;
Simply doing this;
TDDATR + 30 DAYS
But it returned this error: Labeled duration not used correctly.
I tried using the DIGITS and SUBSTR commands to create a field in the DDMMYYYY format and then +30 days but got the same error.
Same as above but in the DD/MM/YYYY format - same error.
Using DATE(TDDATR) but all I see is +'s in the field.
Using DATE( ) on the fields created in step 2 and 3 - still get +'s
I've ran out of ideas - any help would be greatly appreciated.
Query/400 lacks a lot of the features that an SQL based interface has.
I'd urge you to consider switching to Query Manager (STRQM) which is a fully SQL based product. You can even convert Query/400 queries to Query Manager queries with the RTVQMQRY command by having the ALWQRYDFN parm set to *YES.
The other option that IBM is pushing is Web Query. Again, fully SQL based and you can convert Query/400 queries into it.
Having said that, the problem is that FLD + 30 DAYS only works when FLD is a DATE data type. Query/400 includes a DATE() function to convert non-date types into date. But it's very limited in that it only works with character fields formatted according to your job defaults. Assuming you're in the US, it'd only work with a character value of '07/01/15'.
You could do a lot of manipulation in Query/400 and end up with a result field that meets DATE()'s requirements. But a better solution would be to create an SQL view over your table and have your numeric date converted into a date data type in the view.
You can find code examples that show how to convert a numeric YYYYMMDD to a actual date data type in the view. However, I'd recommend create a user defined function (UDF) that will do the conversion for you. That will make it much easier to use in the view and to reuse in other places.
If you'd like, there's an open source package called iDate, that includes all the code required for convert to/from date data types.
Download that, install/compile it and your SQL view becomes
select ... idate(TDDATR,'*CCYMD') as TD_DATE
from myfile
The use of days is as follow
Field Expression
CURDATE_30 days(current(date)) + 30
The solution to your problem is: given the field A dec(8,0)
Field Expression
YYYYMMDD_ date(substr(digits(a),5,2)||'/'||
substr(digits(a),7,2)||'/'||
substr(digits(a),3,2))
NEXT_MONTH DAYS(YYYYMMDD_) + 30
Remember to check the date format in your job description. In the example the format is MDY or MM/DD/YY.
More info here
Based on the information here, I created the below 2 fields;
TDDIGI DIGITS(TDDATR)
TDDAT1 SUBSTR(TDDIGI,7,2)||'/'||
SUBSTR(TDDIGI,5,2)||'/'||
SUBSTR(TDDIGI,3,2)
From here I was able to create a date field;
TDDAT2 DATE(TDDAT1)
Which allowed me to perform the necessary calculations.
The format of TDDAT1 is based on your job description which can be found by;
WRKJOB
Option 2
Page down
Date format..: X
Mine was *DMY, so TDDAT1 was formatted based on this.