Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
aguirre
Creator
Creator

Can I change the format of a field in set analysis

Hello

I have a timestamp field CompletionDate

 

I want to count today's occurrencies of field MyField

 

I see I cannot put something like this as I get an error

Count({<Date(CompletionDate, 'DD/MM/YYYY')={$("=Date(Today(), 'DD/MM/YYYY')")} MyField)

 

and this returns zero 

Count({<CompletionDate={$("=Date(Today(), 'DD/MM/YYYY')")} MyField)

 

How can I count today's coccurrencies then?

 

Labels (2)
1 Solution

Accepted Solutions
mpc
Partner Ambassador
Partner Ambassador

Ok, then if Timestamp format is mandatory it'll be more complicated because you will need a between set analysis (start and end of the day), if not, the best way is to change the format in script to a true date, by using floor/ceil function, combined with formatting ones, and then use the set analysis I've provided. 

From Next Decision and mpc with love

View solution in original post

3 Replies
mpc
Partner Ambassador
Partner Ambassador

Hi, 

If CompletionDate is a true Date field format (you can check it from data model, in tags list $date should be here), then:

Count({<CompletionDate={"$(=Date(Today(),'DD/MM/YYYY'))"}>} MyField) should works if both date display is 'DD/MM/YYYY'. 

Best

From Next Decision and mpc with love
aguirre
Creator
Creator
Author

@mpc  It's a timestamp field not true date

I have made it work with this:

Count({1<CompletionDate={">=$(=Timestamp(Now()-1,'DD/MM/YYYY hh:mm:ss[.fff]'))"},CompletionDate={"<=$(=Timestamp(Now(),'DD/MM/YYYY 23:59:59[.fff]'))"}>} DISTINCT MyField)

but maybe there is a better way and concise way?

mpc
Partner Ambassador
Partner Ambassador

Ok, then if Timestamp format is mandatory it'll be more complicated because you will need a between set analysis (start and end of the day), if not, the best way is to change the format in script to a true date, by using floor/ceil function, combined with formatting ones, and then use the set analysis I've provided. 

From Next Decision and mpc with love