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: 
soha1902
Creator
Creator

Pivot Table

Hi All,

I have following Data:

ProdIDProductActivatedDeactivated
1Prod A02/15/13
2Prod B08/05/13
3Prod C01/07/14
1Prod A02/10/14
2Prod B02/26/14
1Prod A11/15/14

Now my requirement is, if any Product is active then its price will be display as 10 and if it is deactive then its price will be 0.

For example Prod A is activated on 15 feb 2013 and deactivated on 10 Feb 2014 so from 15th Feb 2013 till 10Feb 2014 its price will be 10. On 10th Feb 2014 Prod A was deactivated and on 15 Nov2014 again got activated so from 10th Feb 2014 to 15 Nov 2014 its price will be 0.

I need to add Price column as a expression and Week column should be pivoted.

Can any one suggest me, how to implement this.

The resultant table shold look like this for Product A

ProdIDProductActivatedDeactivated2/18/20142/25/2014-------------'2/7/20142/14/20142/21/2014-------------'11/14/201411/21/2014till cureent date
1Prod A02/15/131010100001010
2Prod B08/05/13
3Prod C01/07/14
1Prod A02/10/14
2Prod B02/26/14
1Prod A11/15/14

Thanks in advance.

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

hi

fix it

have a look

View solution in original post

11 Replies
soha1902
Creator
Creator
Author

any suggestions please.....

saumyashah90
Specialist
Specialist

What about products which doesnt have deactivation date... for example Prod C?

soha1902
Creator
Creator
Author

it will always show Price =10 because it never got deactivated.....

saumyashah90
Specialist
Specialist

Also the Dates shown above should be what?....i mean what should be the period of the dates in the horizontal line?

soha1902
Creator
Creator
Author

Those dates are weekly dates.

lironbaram
Partner - Master III
Partner - Master III

hi have a look at the attach example

have a look at the script where most of the work is done

Not applicable

I know it's maybe a stupid question, but I can see from your example that Prod A  (ID=1) has two activation date...

I think you should add an expression: if=(num(Today())>num(Exp.date),0,10). Then add date as a dimension. I suppose, data is  present in the DB from activation date, therefore you shouldn't have a date renge exceeding the range of the to be analysed dates.

Br,

T

soha1902
Creator
Creator
Author

Hi Liron,

Thanks for your help. It showing correct values for Product A and Product C but not for Product B. Please see below image:

1.png

For Product B it is showing Deactivated date is current date but it excel it was 02/26/2014. see below:

2.png

I attached both qvw and excel file in attachment. Please help to solve this.

lironbaram
Partner - Master III
Partner - Master III

hi

fix it

have a look