Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
etrotter
Creator II
Creator II

GetCurrentSelections

Hi,

Trying to write an if statement with GetCurrentSelections:

If(GetFieldSelections(Week)= Date(Weekend(Today()),'MM/DD/YYYY'),1,0)

my date format is 01/26/2018

Please let me know if you have any ideas on how to get it working.

Thanks!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Adding a Date() formatting function to the left side will not work, since the value you want to format is a text value.

Try interpretation function Date#()

View solution in original post

9 Replies
Thiago_Justen_

Erica,

What is your output? The expression looks like OK (considering that field Week is formated as you said).

Cheers

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
Nicole-Smith

I'm guessing there is a timestamp attached to your field, but you're only concerned about the date.  You can use floor() to ignore the timestamp.  This formula should work:

If(Floor(GetFieldSelections(Week)) = Floor(Weekend(Today())),1,0)

etrotter
Creator II
Creator II
Author

Outputs:

GetCurrentSelections(Week): Week:01/27/2018

Date(Weekend(Today()),'MM/DD/YYYY'): 01/27/2018

I have also tried 'Week:'&Date(Weekend(Today()),'MM/DD/YYYY'): Week:01/27/2018

as

If(GetFieldSelections(Week)= 'Week:'&Date(Weekend(Today()),'MM/DD/YYYY'),1,0) and that still didn't work

OmarBenSalem

Your construction of the weeend date seems to be correct;

but GetFieldSelections(Week) do not return the Week date but sthing like

Week: 01/26/2018

so ur condition has to be sthing like :

if(trim(SubField( GetCurrentSelections(Week),':',2))= Date(Weekend(Today()),'MM/DD/YYYY'),1,0)


per anaogy result if condition is:

if(trim(SubField( GetCurrentSelections(Year),':',2))=max({1}Year),1,0)

Capture.PNG

else

Capture.PNG

Thiago_Justen_

It seems you have a date field formated as a timestamp, as Nicole said. Try Nicole's expression and then tell us what happens.

Cheers

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
etrotter
Creator II
Creator II
Author

I have the week selected and I used:

if(trim(SubField( GetCurrentSelections(Week),':',2))= Date(Weekend(Today()),'MM/DD/YYYY'),1,0)

and its still giving me a zero, I also tried:

if(Date(trim(SubField( GetCurrentSelections(Week),':',2)))=Date(Weekend(Today()),'MM/DD/YYYY'),1,0)

and its still a zero.


Its strange, I both fields into a text object to see their outputs and they are exactly the same, I'm not sure why it refuses to match.

Capture.PNG

swuehl
MVP
MVP

The right value shows a leading zero, and you are comparing the text values char by char.

swuehl
MVP
MVP

Adding a Date() formatting function to the left side will not work, since the value you want to format is a text value.

Try interpretation function Date#()

OmarBenSalem

what if u try as :

if(trim(SubField( GetCurrentSelections(Week),':',2))= Date(Weekend(Today()),'M/DD/YYYY'),1,0)


OR


if(trim(SubField( GetCurrentSelections(Week),':',2))= Date#(Weekend(Today()),'M/DD/YYYY'),1,0)