Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
MarcM
Contributor II
Contributor II

Qlik Sense Find a date in a date range with function

Hello,

I need help comparing a date with a range of dates with a funtion, for example:

Date_A = March-2022

Range_Date = February-2022 March-2022 April-2022

If it matches it should show a value and if not another.

Could you help me please?

Thank you and regards,

Labels (2)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

please post some sample data 

 

temp:
Load *,SubStringCount(RangeDate,DateA) , index(RangeDate,DateA) Inline [
RangeDate,DateA
February-2022 March-2022 April-2022,March-2022
];

outputoutput

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

5 Replies
vinieme12
Champion III
Champion III

you could either use SubStringCount() or Index() for this

if( SubstringCount('March-2022','February-2022 March-2022 April-2022') , then ,else)

or

if(Index('February-2022 March-2022 April-2022','March-2022'), then, else)

 

https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunc...

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
MarcM
Contributor II
Contributor II
Author

This it doesn't work for me... I think the problem is that the data is in variables, Date A is a 1 variable and Range_Date is another variable, they are not manual strings.

vinieme12
Champion III
Champion III

This Works though!; please post your actual script

let DateA = 'March-2022';

let RangeDate = 'February-2022 March-2022 April-2022';

let substrA= SubStringCount('$(RangeDate)','$(DateA)');

let indexA= index('$(RangeDate)','$(DateA)');

substrA is set to 1; <--occurences

indexA is set to 15 ;<--position in string

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
MarcM
Contributor II
Contributor II
Author

Surely I have a mistake...I'm new to this...

for example: SubStringCount([#RANGE_DATE],[#DATE_A]) it's fields not variables sorry

vinieme12
Champion III
Champion III

please post some sample data 

 

temp:
Load *,SubStringCount(RangeDate,DateA) , index(RangeDate,DateA) Inline [
RangeDate,DateA
February-2022 March-2022 April-2022,March-2022
];

outputoutput

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.