Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Tmerinol
Contributor II
Contributor II

Compare between two time periods

Hi all,

I have an historical database where I have the orders for different products for the company (sold + forecast) for the year 2021. I have the historical data since 01.01.2021 for every day until now and i want to compare the percentual change between the amounts (sold + forecast) in different periods of time but limitating this just to two periods (otherwise it would not possible to compare three periods)

 

For example:  compare the percentual difference for all the articles between the 04.09.2021 and 01.09.2021, or between today and yesterday or between two random dates (that the user can choose).

I would like to know if it is possible to do this with a Pivot Table in Qlikview

Dataset would be: 

Amount of orders and sold articles for diferents products for the year 2021 
Artikel01.09.202102.09.202103.09.202104.09.2021
A10152020
B20254045
C30305040

 

Expected Result would be (for the selected dates): 

   
Artikel03.09.202104.09.2021Difference between selected datum 1 (04.09.2021) and datum 2 (03.09.2021)
A1004040,00%
B402255,00%
C504080,00%

 

Thanks a lot in advance!

1 Solution

Accepted Solutions
MayilVahanan

Hi @Tmerinol 

Hope the user will select max 2 random dates, in that case, try like below

Dim: Artikel

Exp1: Sum({<DateField={'$(=Date(Min(DateField)))'}>}Sales)

Exp2: Sum({<DateField={'$(=Date(Max(DateField)))'}>}Sales)

Exp3: Num(Sum({<DateField={'$(=Date(Max(DateField)))'}>}Sales) / Sum({<DateField={'$(=Date(Min(DateField)))'}>}Sales), '# ###,##%')

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

4 Replies
MayilVahanan

Hi @Tmerinol 

Hope the user will select max 2 random dates, in that case, try like below

Dim: Artikel

Exp1: Sum({<DateField={'$(=Date(Min(DateField)))'}>}Sales)

Exp2: Sum({<DateField={'$(=Date(Max(DateField)))'}>}Sales)

Exp3: Num(Sum({<DateField={'$(=Date(Max(DateField)))'}>}Sales) / Sum({<DateField={'$(=Date(Min(DateField)))'}>}Sales), '# ###,##%')

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Vegar
MVP
MVP

it is possible to do, but I would recommend you to normalise your data set in order to do do. 

Try to transform your data into this format.

|Artikel|Date|Amount|

|A|01.09.2001|10|

|A|02.09.2001|15|

|B|01.09.2001|20|

|B|02.09.2001|25|

 

You could try to achieve this by using the CROSSTABLE functionality in your load script.

 

When you have done this,  then you could look at @MayilVahanan 's reply in order to get a correct measure expression. 

 

 

Tmerinol
Contributor II
Contributor II
Author

Hi ,

Thanks for the reply. I have already the data normalised. 

I tried the formulas you said but it is not working. I dont know why.

In this case i have the dimension "Artikel". the variable "von" means "Date" and absatz are the "Sales". 

I wrote the three expressions but they seems to not work. 

What should i do`?

Tmerinol_0-1631196774439.png

 

Tmerinol
Contributor II
Contributor II
Author

@MayilVahanan  your solution worked for me. I realized that i had a format problem (with the dates). I fixed that and now works!

Thank you very much!!