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: 
nareshthavidishetty
Creator III
Creator III

Logic at script end -Derive Day level using MTD

Hi,

I need to derive day level data using MTD. Below is the scenario,

1- We were having only MTD data.

2- To get day level data we need to do arithmetic calculation as MTD sales count on today - MTD sales count  on Yesterday will get Sales for today.

EX: 5/11/2016 sales = MTD 5/11/2016 sale - MTD 5/10/2016 sales

Now we have to implement this logic at Script level.

May i know logic to write at script level.

Note: DATE = SYSDATE

Thanks..

4 Replies
sunny_talwar

May be like this:

Table:

LOAD *,

  MonthName(Date) as MonthYear;

LOAD * Inline [

Date, MTDSales

01/01/2016, 50

01/02/2016, 80

01/03/2016, 90

02/01/2016, 10

02/02/2016, 40

02/03/2016, 70

];

FinalTable:

LOAD *,

  If(MonthYear = Peek('MonthYear'), MTDSales - Peek('MTDSales'), MTDSales) as Sales

Resident Table

Order By Date;

DROP Table Table;

nareshthavidishetty
Creator III
Creator III
Author

Hi,

This haven't gave day level data.Please find below image.

I need to derive one day data from MTD.

Untitled.png

Thanks..

sunny_talwar

If you add Date and Sales in a table box you will see the day level sales. If this is not what you want, may be elaborate and provide a sample with expected output

Not applicable

Temp:

LOad * INline [

Date, Amount

05/11/2016, 250

05/10/2016, 220

05/09/2016, 200

05/08/2016, 150

];

Final:

Load *,

    Amount-Previous(Amount) as NewAmount

    Resident Temp

    Order by Date Asc;

   

Drop table Temp;

Capture.PNG