Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
alespooletto
Creator
Creator

How to pivot a table on datetimes as values?

I was able to create this pivot table with the desired values as columns, but the problem is with the values. I want to show DateTimes as values under these columns, but how can i do so?

alespooletto_0-1702301368809.png

 

Labels (2)
1 Solution

Accepted Solutions
vincent_ardiet_
Specialist
Specialist

The default script of autoCalendar is doing a Floor on the original date, so this is removing the time.
If you want to see it, use the original field linked to it [Date]:
Max([Date])

View solution in original post

12 Replies
vincent_ardiet_
Specialist
Specialist

What is your expression? We can only see a portion of it.

alespooletto
Creator
Creator
Author

It's 

 

Max([Date.autoCalendar.YearsAgo])

vincent_ardiet_
Specialist
Specialist

YearsAgo returns the number of past years between your stored dates and today. So, this is excepted not to see a date.
You need to pick another field like autocalendar Date or basically the original date field of your datamodel (specially if you want also the time).
Max([Date.autoCalendar.Date])

alespooletto
Creator
Creator
Author

Thank you, this indeed does show dates instead of numbers. The thing is, I was interested in knowing the DateTime,  but I cannot seem to find an autoCalendar.DateTime, is there a workaround for this?

vincent_ardiet_
Specialist
Specialist

The default script of autoCalendar is doing a Floor on the original date, so this is removing the time.
If you want to see it, use the original field linked to it [Date]:
Max([Date])

alespooletto
Creator
Creator
Author

Thank you @vincent_ardiet_ ,it seems this does show dates still, not datetimes. 

 

EDIT: I was using the wrong field, this shows the datetime as you mentioned it would. 

vijay121
Contributor
Contributor

Pivoting a table on date times as values typically involves transforming a dataset where date-time values are stored in rows into a structure where those date times become column headers.

Keep in mind that if you have duplicate entries for the same date-time value, the pivot function won't work unless you first handle these duplicates. You may need to aggregate or transform the data accordingly before pivoting.

alespooletto
Creator
Creator
Author

Is there a way to sort the pivot table by the datetimes? As I want to sort by the earliest to the latest datetime @vincent_ardiet_ 

vincent_ardiet_
Specialist
Specialist

Yes if you go in the "Sorting" section, you will see "Sort by first measure" (according to the fact that your max(Date) expression is still the first one).