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

Subtract one for specified date

If [EndDate] is equal to any of these dates (2/9/2019, 2/16/2019, 2/23/2019) then I want

[FinalDifference] = [PreDifference] – 1 

EndDate

PreDifference

FinalDifference

2/1/2019

1

1

2/9/2019

1

0

2/16/2019

1

0

2/17/2019

1

1

2/23/2019

1

0

 

Unfortunately I am putting 2/23/2019 into [FinalDifference] instead, can you help?

 

[FindDate]:
LOAD Concat(Chr(39) & [SubtractDate] & Chr(39), ',') as DateTable
;
LOAD *
INLINE [
SubtractDate,
2/9/2019,
2/16/2019,
2/23/2019,
]
;

Let vDateTable = Peek('DateTable');
DROP DateTable [FindDate];


[Summary]:
EndDate,
PreDifference,
IF([EndDate] = $(vDateTable),[PreDifference]-1) AS [FinalDifference]
RESIDENT [PreSummary];

 

 

 

 

1 Solution

Accepted Solutions
PrashantSangle

try with mapping load. try below logic

map1:
mapping LOAD *
INLINE [
EndDate,Flag
2/9/2019,1
2/16/2019,1
2/23/2019,1
]
;

[Summary]:
Load *,
IF(Flag=1,[PreDifference]-1) AS [FinalDifference];
Load *,
Applymap('map1',EndDate,'0') as Flag
EndDate,
PreDifference
RESIDENT [PreSummary];

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

1 Reply
PrashantSangle

try with mapping load. try below logic

map1:
mapping LOAD *
INLINE [
EndDate,Flag
2/9/2019,1
2/16/2019,1
2/23/2019,1
]
;

[Summary]:
Load *,
IF(Flag=1,[PreDifference]-1) AS [FinalDifference];
Load *,
Applymap('map1',EndDate,'0') as Flag
EndDate,
PreDifference
RESIDENT [PreSummary];

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂