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

Calculating data from resident table

Hi guys,

I am loading data from an SQL database. I have two columns: date and volume and in my SQL query I limit data to the last 8 weeks. Like this:

MyTable:

LOAD testdate, volume;

SELECT

    CAST(timestamp AS DATE) as testdate

    SUM(volume) as volume,

FROM $(dbname).dbo.TestTable

WHERE timestamp >= DATEADD(week,-8, GETDATE())

GROUP BY CAST(timestamp AS DATE)

I now wish to create a new Qlik table where I have the following columns:

date || volume || volume same day last week || volume (8 week average)

The point is that I only wish to have rows for the last 7 days in my new table, but I need 8 weeks of data to calculate data for all rows in the new table. How would I go about calculating data for the last two columns?

I am new to Qlik and Im not sure about the syntax.

Thanks!

Best Regards,

Rasmus

1 Reply
rasmusnielsen
Partner - Creator
Partner - Creator
Author

Ok, so the "volume same day last week" column is calculated using:

Peek(volume, RowNo()-7) as volumeLastWeek

I will continue to find out to calculate the last column.