Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
pavandbs
Contributor III
Contributor III

Need help in Qlikview scripting

Hello All,

I am brainstorming to get the desired output for the below requirement.

      

Transaction DateDealPrev_DealSales MarginDerived FieldStatus
30-Jul-1612345010001000Dead
1-Aug-16678901234520001000Dead
2-Aug-16678916789040003000Dead
3-Aug-16678926789150004000Dead
1-Sep-16678896789270002000Live

I need to calculate the derived field based on Month

1. As of 30-Jul-2016 Transaction date I have reported 1000 Sales Margin. (As of 30-Jul-2016 Status is also only)

2. On 1-Aug-2016 67890 is inserted, deal 12345 is parent. Since for Jul I have reported 1000 for Aug I have to report 2000-10000=1000 is my derived field. For deal 67891,same as 67890. At the end of Aug I have reported 4000

3. On 01-Sep-16 since I have reported 4000, now I should report 7000-4000.

Please advice how I derive the logic. All the Deal and Prev_Deal are interlinked and are in one package.

12 Replies
ToniKautto
Employee
Employee

Hi Pavan,

from my understanding there is not a one-step way to accomplish your requirement in the load script. I would suggest looking at flagging the data so that you can aggregate the number over each deal path and per month within the deal path.

In the attached example I have used the Hierarchy load prefix to group the deals over the first deal in the chain of deals. The date value then needs to be reformatted to a month to allow the second level of grouping. In this example I used Month Start to find what month each date belongs to.

With these two grouping you will have to find a way to aggregate the derived value as you expect. I am not sure exactly what the best approach for the aggregation would be.

pavandbs
Contributor III
Contributor III
Author

Hi Toni,

Thanks a lot for quick turn around. Logic looks good, however when I reload Derive column is disappearing. Did I miss some thing ? I mean in script the couldn't see Derive column

ToniKautto
Employee
Employee

Hi Pavan,

sorry, I accidentally left the derive field in the sample, after trying to find a quick way to add it. As I mentioned above I am not able to find a simple solution to your required logic.

The main complexity I struggled with is that you need to aggregate per month within one deal path, and then carry over result  to next month. I did not find a simple way to do that. My assumption is that you might need to flag the aggregated intervals and then aggregate the intervals. I think you mentioned trying to do this thought FOR loops or similar, have you tried that approach?