Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
PetitFoulard
Contributor II
Contributor II

Date Format based on Variable

Hi all,

A quick question on dates and variable dates ...

I have, on my dashboard, a Variable Input with two buttons. The two buttons will switch a value between 0 or 1, respectively.

I also have a KPI chart, which displays a date. The only thing is, if the value in my Variable Input is set to 1, I'd like the date format to be "MMM DD hh:mm:ss". And if the Variable Input is set to 0, I'd like the date format to be "DD hh:mm:ss".

In my KPI expression, I have tried something like:

If (vButton = 1,
vDateFormat = DateFormat(MMM DD hh:mm:ss),
vDateFormat = DateFormat(DD hh:mm:ss))

vDateFormat

But it does not seem to work ...
I have also tried defining a new date format in my data load editor, and calling that instead.

If (vButton = 1,
vDateFormat = DateDisplay1,
vDateFormat = DateDisplay2)

vDateFormat

No luck there either. Does anyone know how to accomplish this? It seems like it should be pretty easy, but I have not been able to locate anything online so far.

Cheers and thanks for any assistance.

 

Labels (4)
1 Solution

Accepted Solutions
PetitFoulard
Contributor II
Contributor II
Author

Scratch that, just solved it ... it was pretty easy. Sorry all. It was just a matter of setting the KPI Number fomatting option to Measure expression. Then the expression was:

if (vButton = 1,
DATE($(DateFormat), 'MMM-DD hh:mm:ss'),
DATE($(DateFormat), 'DD hh:mm:ss'))

 

Don't mind me, I'll see myself out lol

View solution in original post

1 Reply
PetitFoulard
Contributor II
Contributor II
Author

Scratch that, just solved it ... it was pretty easy. Sorry all. It was just a matter of setting the KPI Number fomatting option to Measure expression. Then the expression was:

if (vButton = 1,
DATE($(DateFormat), 'MMM-DD hh:mm:ss'),
DATE($(DateFormat), 'DD hh:mm:ss'))

 

Don't mind me, I'll see myself out lol