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: 
johnca
Specialist
Specialist

Nested IF - Need Help Deciphering

I've been given the task of updating/fixing a dashboard (I did not create) and am stuck deciphering a nested IF statement. It has to do with 2 dates, and what day of the week they fall on, and whether to alter the original date and create a new date, or not, I believe. Can someone look at the statement below and turn it into a word problem so I can understand what the original author was trying to do?

I think it starts out with:

If Creation Date - Request Date < 0.5 ThenRequest Date + 3 Else Request Date + 2) = Sun Then...(and I get lost)

Here is the code:

if(WeekDay((

if(("CREATION_DATE"-"REQUEST_DATE") <.5,("REQUEST_DATE"+3),("REQUEST_DATE"+2)))) = 'Sun', ((

if(("CREATION_DATE"-"REQUEST_DATE") <.5,("REQUEST_DATE"+3),("REQUEST_DATE"+2)))+2),

if (WeekDay(

if(("CREATION_DATE"-"REQUEST_DATE") <.5,("REQUEST_DATE"+3),("REQUEST_DATE"+2))) = 'Sat', ((

if(("CREATION_DATE"-"REQUEST_DATE") <.5,("REQUEST_DATE"+3),("REQUEST_DATE"+2)))+2), (

if(("CREATION_DATE"-"REQUEST_DATE") <.5,("REQUEST_DATE"+3),("REQUEST_DATE"+2))))) AS NEW_REQUEST

Thanks All,

John

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

It calculates a new request date NEW_REQUEST. If the difference between CREATION_DATE and REQUEST_DATE is less than half a day, then add three days to REQUEST_DATE otherwise add two days. That yields a new date. If the new date is a Sunday or a Saturday add another two days. Call the result NEW_REQUEST.


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

It calculates a new request date NEW_REQUEST. If the difference between CREATION_DATE and REQUEST_DATE is less than half a day, then add three days to REQUEST_DATE otherwise add two days. That yields a new date. If the new date is a Sunday or a Saturday add another two days. Call the result NEW_REQUEST.


talk is cheap, supply exceeds demand
johnca
Specialist
Specialist
Author

I knew someone here could figure that out! Thanks Gysbert!

ninjasoft
Contributor
Contributor

I was asked to help on a project and never seen a nested if like this below and for the life of me can't Decipher it - please help

 

=if (Month([AsOfDate]) & Year([AsOfDate]) = Month( MakeDate(  if( [CalendarMonth]>=10, [OOPlan.FiscalYear]-1, [OOPlan.FiscalYear]),[CalendarMonth],1)) & Year( MakeDate  (if([CalendarMonth]>=10,[OOPlan.FiscalYear]-1, [OOPlan.FiscalYear]), [CalendarMonth],1)),[AsOfDate.autoCalendar.YearMonth], null())

 

also if someone can point me to a place i can read up, but i can't make heads or tails of where constructs make any sense, like where is the then and else in this convoluted concatenation - thanks 

Saravanan_Desingh

=if (Month([AsOfDate]) & Year([AsOfDate]) = Month( MakeDate(  
														if( [CalendarMonth]>=10, [OOPlan.FiscalYear]-1, [OOPlan.FiscalYear])
														,[CalendarMonth]
														,1
													)//MakeDate
											)//Month 
												   & 
											Year( MakeDate  (
												   		if([CalendarMonth]>=10,[OOPlan.FiscalYear]-1, [OOPlan.FiscalYear])
												   		, [CalendarMonth]
												   		,1
												  )//MakeDate
											)//Year
	,[AsOfDate.autoCalendar.YearMonth]	//Then
	,null()								//Else
)//If