Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
rduah4u
Contributor II
Contributor II

Crosstable Dates disappear

Hi, 

I have an existing Dates table and I also have some data from an excel file that contains dates which im trying to align with my main dates table to interact dynamically and pull the right data for the required dates. 

The date field in my main Dates table is called DatesTrans - when i look at my model both tables are joined by the DatesTrans but i dont see any dates in the Data table - Example below:

BlockID, DatesTrans, Blocks

101             -                  2

103             -                  5

tmpdata:
Crosstable (Date, Block,1)
LOAD
*
FROM XYZ
;

Data:
NoConcatenate
LOAD

BlockID, 
date(num#(Date)) AS DateTrans,
Blocks
Resident tmpdata;
Drop Table tmpdata;
Exit Script;

I'm not sure if it has anything to do with the fact that the DateTrans field in my Dates table is an Interger in the DW formatted as 20240131. This is the main field used across all tables/reporting.

 

 

Labels (1)
2 Solutions

Accepted Solutions
marcus_sommer

The blank-char isn't a space-char else it's a tab-char respectively chr(9). I'm not sure if it's fetched by trim() but the following should be working:

date(date#(purgechar(Date, chr(9)),'YYYY-MM-DD'),'YYYYMMDD') AS DateTrans

View solution in original post

lennart_mo
Creator
Creator

Trim() seemed to work for me, but purgechar() for sure is safer to use.

I think your suggested formula might pose another problem though, since the DateTrans from @rduah4u's table seems to be just an integer with no date-tag, so i would encapsulate your entire formula in a num#() to get the date-text as an integer and not the date-value.

View solution in original post

13 Replies
Padma123
Creator
Creator

num#(Date) as DateTrans

rduah4u
Contributor II
Contributor II
Author

num#(Date, 'YYYYMMDD') AS DateTrans - When i apply this the format is still in it's original context 2024-04-01 Whereas i need it as YYYYMMDD?

Padma123
Creator
Creator

date(NUM#(date),'YYYYMMDD')

rduah4u
Contributor II
Contributor II
Author

rduah4u_0-1721388076737.png

Unfortunately it disappears again! 

marcus_sommer

Try it with: date(date#(YourField),'YYYYMMDD'), 'YYYYMMDD')

rduah4u
Contributor II
Contributor II
Author

Still no good! Have no idea what this could be for something really seemingly simple. I've attached the CSV file. As previously mentioned i have a sperate QVD File for my Dates table

 

Dates:
LOAD
DateTrans
FROM [XYZqvd]
(qvd);

tmpdata:
Crosstable (Date, AppData,1)
LOAD
*
FROM [XYZ.csv]
;

Data:
NoConcatenate
LOAD
date(date#(Date,'YYYYMMDD'),'YYYYMMDD') AS DateTrans,
AppData AS BLOCK
Resident tmpdata;

Drop Table tmpdata;
Exit Script;

marcus_sommer

Have you adapted YourField to your existing field?

The logic itself is simple - convert the string with the appropriate format-pattern and then applying the wanted formatting again with the format-pattern or without in which the default formatting is applied. You may take a look on the interpretation-variables at the begin of the script which are the base for the interpretation.

rduah4u
Contributor II
Contributor II
Author

I've tried this several times in various ways. Attached is an example of the csv file. 

My DateTrans field in the DW is (PK, int, not Null) - Will be grateful if you can try and replicate:

Dates:
LOAD

DateTrans
FROM [XYZ.qvd]
(qvd);

tmpdata:
Crosstable (Date, AppData,1)
LOAD
*
FROM [XYZ.csv]
;

Data:
NoConcatenate
LOAD

BLOCKID,
date(date#(Date,'YYYYMMDD'),'YYYYMMDD') AS DateTrans,
AppData AS BLOCK
Resident tmpdata;

Drop Table tmpdata;
Exit Script;

marcus_sommer

The format from date within the csv is different to your description and not YYYYMMDD else YYYY-MM-DD and therefore the transformation should be look like:

date(date#(Date,'YYYY-MM-DD'),'YYYYMMDD') AS DateTrans