Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Milaf
Contributor III
Contributor III

How do I use the selected date field in an if statement?

Hi all,

I use 2 Pivot on my dashboad. The user selects the period from the filters (Daily, Weekly, Monthly), if user wants can select a post-period date. The first pivot changes according to this selection. The 2nd pivot should write the previous value so that the selection can be compared. For example, if daily is selected today or selected day-1, if weekly is selected this week or selected week-1. My attempts did not work. It is a very urgent need, can anyone help?

if(GetFieldSelections([Period]='Daily'), vYesterday),
if(GetFieldSelections([Period],'Weekly'),vPreviousWeek)
if(GetFieldSelections([Period],'Monthly'),vPreviousMonth))))

//

if(Wildmatch(GetFieldSelections([Period],'Daily')'$(Yesterday)'),
if(Wildmatch(GetFieldSelections([Period],'Weekly')'$(Yesterday)')
if(Wildmatch(GetFieldSelections([Period],'Monthly')'$(vPreviousMonth)')

Labels (4)
4 Replies
brunobertels
Master
Master

Hi 

May be this 

if(GetFieldSelections([Period]='Daily'), $(vYesterday)),
if(GetFieldSelections([Period],'Weekly'),$(vPreviousWeek))
if(GetFieldSelections([Period],'Monthly'),$(vPreviousMonth)))))

Milaf
Contributor III
Contributor III
Author

Thank you for your answer. Finally, I tried the one below, but the monthly one never works. I could not get the total of the previous month 😞

=if(GetFieldSelections([Period])='Daily',sum({<DATE= {'$(vYesterday)'}>} IPCOUNT),
if(GetFieldSelections([Period])='Weekly',sum({<DATE= {'$(vPreviousWeek)'}>} IPCOUNT),
if(GetFieldSelections([Period])='Monthly', sum({<MONTH= {'$(vMonthly)'}>} IPCOUNT)
)))

Milaf
Contributor III
Contributor III
Author

My Monlty variable is; 
     =Date(MONTH-31, 'DD.MM.YYYY')

I wrote above "sum({<MONTH= {'$(vMonthly)'}>} IPCOUNT) " works when I write 01.10.2023 instead of the variable in the formula. "sum({<MONTH= {'01.10.2023'}>} IPCOUNT) but it does not detect the variable value even though it is correct.

brunobertels
Master
Master

hi 

may be like this : 

   =Date(addmonth(MONTH,-1), 'DD.MM.YYYY')