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: 
yh2023
Contributor III
Contributor III

GetFieldSelections for Date in if statement

Hello,

I have a field pt_YH_FY_month_year which has Dates in format 'MMM-YYYY'.

I'm attempting to compare the field pt_YH_FY_month_year with a date generated from the user's selection using the following expression:

=if(pt_YH_FY_month_year = date(date#(SubField(GetFieldSelections(pt_YH_FY_month_year),',',3), 'MMM-YYYY'), 'MMM-YYYY'), 1, 0)

The output from date(date#(SubField(GetFieldSelections(pt_YH_FY_month_year),',',3), 'MMM-YYYY'), 'MMM-YYYY') produces dates in the format 'Apr-2022'. However, when I compare pt_YH_FY_month_year to this date format, they don't match as expected.

Here's an attachment for reference:

I would greatly appreciate any insights or suggestions on why the comparison isn't working as intended

Labels (3)
1 Solution

Accepted Solutions
Anil_Babu_Samineni

In general, last row should match.

Anil_Babu_Samineni_0-1702614259705.png

 

I will do like this when you compare, because some of the functions or direct field won't match exactly due to Trim or funny formats. Try this?

If(date(pt_YH_FY_month_year, 'MMM-YYYY')=date(date#(SubField(GetFieldSelections(pt_YH_FY_month_year),',',3), 'MMM-YYYY'), 'MMM-YYYY'), 1,0)

 

To play around more, please share sample QVF with us.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

1 Reply
Anil_Babu_Samineni

In general, last row should match.

Anil_Babu_Samineni_0-1702614259705.png

 

I will do like this when you compare, because some of the functions or direct field won't match exactly due to Trim or funny formats. Try this?

If(date(pt_YH_FY_month_year, 'MMM-YYYY')=date(date#(SubField(GetFieldSelections(pt_YH_FY_month_year),',',3), 'MMM-YYYY'), 'MMM-YYYY'), 1,0)

 

To play around more, please share sample QVF with us.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful