Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Akina0929
Creator
Creator

how to add columns dynamically in straight table?

Hi,

  I have table that consist

Pid,  Pname

1      ,mango

2      ,coriander

3      ,pepper

if the pid again comes it needs to same columns beside like following

pid, pname,     pid,   pname

1   ,mango,       1    , banana

2   ,coriander

3   ,pepper        3    ,sapota

dynamically it needs to add columns to table if the same pid is comimg again and again . how can i achieve please help me.

25 Replies
satheshreddy
Creator III
Creator III

Hi Anil,

thanks,

if its have n no of records with multiple dist,tal,mundal how we can achieve.

we need three columns dynamically if values are different.

we will get dynamically columns in this situation?

Regards

Sathish

vishsaggi
Champion III
Champion III

May be try this? This will dynamically create the fields based on number of Distinct statecodes.

Table1:

LOAD statecode, Concat(dist,';') AS distance

Group By statecode;

LOAD * INLINE [

statecode  ,dist

111 ,       guntur

111 ,       prakasam

111 ,       ongole

222 ,       adilabad

222 ,       khammam

333 ,       vadi

444,        Guntur

444,        Vadi

444,

555,        Ongole

555,        Vadi

555,        khammam

555,        Adilabad

555,        Guntur

666,        Prakasham

666,        Karimnagar

];

ISLAND:

LOAD DISTINCT statecode AS stateCnt

Resident Table1;

LET vCnt = NoOfRows('ISLAND');

For i = 1 to $(vCnt)

NoConcatenate

Table1:

LOAD statecode,

subfield(distance, ';', $(i)) AS dist$(i)

Resident Table1;

Next i ;

Drop Table Table1;

Capture.PNG

satheshreddy
Creator III
Creator III

Hi Vishwarath Nagaraju,

can you share me the qvw file am getting wrong result.

Regards

Sathish

qlikview979
Specialist
Specialist

Hi

PFA

Regards

vishsaggi
Champion III
Champion III

Here it is.

satheshreddy
Creator III
Creator III

Hi Nagaraju,

1).here each dist we are creating one column but if we have 10000 number off rows we will get 10000 columns right?

here for loop will create huge columns.

2). one more thing here i need to check 3 columns and need to provide three separate columns for each record.

Regards

Sathish

Not applicable

for just having three column you can change the for loop counter.

just change $(vCnt) with three in Nagaraju Code.

satheshreddy
Creator III
Creator III

Hi Agarwal,

here we are getting lots off tables if records have 1cror what should need to do, we cant create  1 cror tables here right?

i need front end Possibility to create dynamical columns.

Ex: if 1 record have 5 different dist that five need to convert separate columns.

if we have 1 record 1000 different dist how we can we cont store that much tables in data model it will give performance issue surely

Regards

Sathish

vishsaggi
Champion III
Champion III

Yes, it will not load properly and can freeze. So what exactly your requirement and why you need like 1000 columns, i am pretty much sure any User would like or have time to view those 1000 columns or how many ever. Picking up the most important columns should be your priority.

However, what is your actual data source and how the data looks can you explain a little more in your requirement?

I am sorry was this your requirement or you just wanted to know what happens if we have 1000 rows of data coming?

satheshreddy
Creator III
Creator III

Hi Nagaraju,

my users asking based on one CID they want to see 1 product id as a column like how many products they purchased that all products they want to see in columns and also product weight also separate columns each product wise  like this my user requirement.

finally they want like below.

CID  PID   Pweight   PID    Pwieght   .........

1). here they want dynamically columns generation based on products.

2). they want to compare each CID.

Regards

Sathish.