Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
thannila
Creator
Creator

Cross Table

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;





can anyone explain this code?

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)';





My doubt is how we are getting the sales value here?


1 Solution

Accepted Solutions
olivierrobin
Specialist III
Specialist III

hello

for i=1 to number of values of field month

vField=value of ith occurence of month

left join existing table and adding new column named with the month name and containing the value of the month

at the end, on each row, you have 5 more columns named Jan 2017, ... Jun 2017

View solution in original post

5 Replies
olivierrobin
Specialist III
Specialist III

hello

for i=1 to number of values of field month

vField=value of ith occurence of month

left join existing table and adding new column named with the month name and containing the value of the month

at the end, on each row, you have 5 more columns named Jan 2017, ... Jun 2017

thannila
Creator
Creator
Author

But how we are getting the sales value???

olivierrobin
Specialist III
Specialist III

here

Sales as [$(vField)]


the field Sales is left joined under the name contained in the field vField

thannila
Creator
Creator
Author

Thank you for your explanation.But instead of using this we can use generic load.

olivierrobin
Specialist III
Specialist III

generic load will create 1 table per month value

all depends on your needs