Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Folks,
my situation does look like: i have this table:
Produc, Month, Sales
A, Jan 2017, 10
A, Mar 2017, 20
A, Apr 2017, 30
B, Mai 2017, 40
B, Jun 2017, 50
i want to convert this table into following table:
Product, Jan 2017, Mar 2017, Apr 2017, Mai 2017, Jun 2017
A, 10 20 30 0 0
B 0 0 0 40 50
Does have anybody any idea?
Thanks a lot for your feedback and help
Beck
May be this
Table:
LOAD * INLINE [
Product, Month, Sales
A, Jan 2017, 10
A, Mar 2017, 20
A, Apr 2017, 30
B, Mai 2017, 40
B, Jun 2017, 50
];
FinalTable:
LOAD DISTINCT Product
Resident Table;
For i = 1 to FieldValueCount('Month')
LET vField = FieldValue('Month', $(i));
Left Join (FinalTable)
LOAD DISTINCT Product,
Sales as [$(vField)]
Resident Table
Where Month = '$(vField)';
Next
DROP Table Table;
You are looking for The Generic Load and not CrossTable load here.
Hi Sunny, thanks a lot for your help and feedback
i tried the code from this issue, but i can.t solve it, do you have any alternative ideas?
Thanks a lot
Beck
Can I suggest to symply create a pivot table and drag and drop "Month" dimension above the header of the Measure sum(sales) ?
Hi Michele,
First of all, thanks a lot for help and idea, but what shoul i do, if i should use a few dimension? and dont forget i am using Qlik Sense not QlikView
Thanks a lot
Beck
May be this
Table:
LOAD * INLINE [
Product, Month, Sales
A, Jan 2017, 10
A, Mar 2017, 20
A, Apr 2017, 30
B, Mai 2017, 40
B, Jun 2017, 50
];
FinalTable:
LOAD DISTINCT Product
Resident Table;
For i = 1 to FieldValueCount('Month')
LET vField = FieldValue('Month', $(i));
Left Join (FinalTable)
LOAD DISTINCT Product,
Sales as [$(vField)]
Resident Table
Where Month = '$(vField)';
Next
DROP Table Table;
For qliksense is the same.
You can do that with more than one dimension.
Sunny, thanks a lot for your help,
i overlooked a variable in code, now i solved my problem
Thanks a lot
Beck
Sunny - This script you posted bailed me out so thanks!
Hi Sunny,
many thanks for your help, I found this solution very helpful when in comes to table "pivoting".
Could you please help me with the next step related to this sript. After I completed loop, I need to set all cell where there is no value to "0". Could you please help me we that? What would be a script.
There is a part of my sript :
Many thanks for your help
Best regards