Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
bellesol
Creator
Creator

Add condition to if match

Hi,

I have the following calculate dimension:

=if(match(TYPE,'2041','2500','4000','2044','2040','3000','4990','3070','3090','2598') ,'2,000',if(match(TYPE,'1010') ,'0','1,000'))

this dimension display all the types from all the years, how can I added two condiotions to the calculation::

Year=year(Today())

month=Month(Today())

so the types that will be displayed are the types for current year and month

 

Thanks!

1 Solution

Accepted Solutions
Kushal_Chawda

I would suggest you to move this if calculation to script as cal calculated dimension can cause performance issue.

LOAD*,

if(match(TYPE,'2041','2500','4000','2044','2040','3000','4990','3070','3090','2598') ,'2,000',if(match(TYPE,'1010') ,'0','1,000')) as TypeNew

Now your can use the simplify version of calculated dimension.

=aggr(only({<Year={"$(=year(today()))"},Month={"$(=month(today()))"}>}TypeNew) ,TypeNew)

 

If you further want to improve the expression, you can create a Flag for current year and current month condition is script

=if(year=year(today()) and month =month(today()),1,0) as Flag

Then instead of calculated dimension you can use the Flag in Expression set analysis with dimension TypeNew

View solution in original post

4 Replies
Kushal_Chawda

I would suggest you to move this if calculation to script as cal calculated dimension can cause performance issue.

LOAD*,

if(match(TYPE,'2041','2500','4000','2044','2040','3000','4990','3070','3090','2598') ,'2,000',if(match(TYPE,'1010') ,'0','1,000')) as TypeNew

Now your can use the simplify version of calculated dimension.

=aggr(only({<Year={"$(=year(today()))"},Month={"$(=month(today()))"}>}TypeNew) ,TypeNew)

 

If you further want to improve the expression, you can create a Flag for current year and current month condition is script

=if(year=year(today()) and month =month(today()),1,0) as Flag

Then instead of calculated dimension you can use the Flag in Expression set analysis with dimension TypeNew

bellesol
Creator
Creator
Author

Thanks, it worked!

I'm sorry for the basic questions,

why did you use aggr? and why did you use the sign "$" in the set analysis?

Kushal_Chawda

Also please don't forget to mark the reply as correct