Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
nougatitati
Contributor III
Contributor III

Swapping columns and rows

Hi,

I have a table that looks like this:

SubjectAvg1Avg2Avg3Avg4
s1a1b1c1d1
s2a2b2c2d2
s3a3b3c3d3
...............

 

But I want to make a visualisation that compares averages against each other, i.e. using 'average context' as a dimension, where each 'context' is just avg1, avg2, avg3, avg4. To this end, I think I need a table that looks like this:

Contexts1s2s3...
Avg1a1a2a3...
Avg2b1b2b3...
Avg3c1c2c3...
Avg4d1d2d3...

 

I thought I should use the CrossTable keyword, but I don't know how to get it working properly; I get errors regarding data connections et cetera when I have these tables already loaded in other places. How can I get the table layout I need?

 

EDIT: I found this and this about the so-called Generic Load. I tried this, but it had some bizarre side effects (it created several tables and did not have all the rows in fields as I had hoped).

 

SwappedRowColumnTable:
Generic Load * Resident OriginalTable;

 

Is this the right idea? How can I get it working?

1 Solution

Accepted Solutions
Channa
Specialist III
Specialist III

AvgTable:
Load
    [Subject],
    Interval(Avg([timeelapsed1]), 'hh:mm:ss') as [Avg time1],
    Interval(Avg([timeelapsed2]), 'hh:mm:ss') as [Avg time2],
    Interval(Avg([timeelapsed3]), 'hh:mm:ss') as [Avg time3]
Resident TimeElapsedTable
Group by [Subject];

CrossTable(AVG, TIME)
 LOAD  Subject,AvgTime1,AvgTime2,AvgTime3 resident AvgTable

if this dosent work try to load previous table into QVD instead of resident load from QVD

Channa

View solution in original post

4 Replies
Channa
Specialist III
Specialist III

swap column to row use 

crosstable(Avg,sales)

try to keep s1 ,s2 as second column and use generic load

 

Channa
nougatitati
Contributor III
Contributor III
Author


@Channa wrote:

swap column to row use 

crosstable(Avg,sales)

try to keep s1 ,s2 as second column and use generic load

 


Sorry I don't understand what you mean at all. What do you mean by crosstable(Avg,Sales)? Do you mean subject?

Maybe it'll help if I give some more sample stuff.

My data load looks something like this:

 

AvgTable:
Load
    [Subject],
    Interval(Avg([timeelapsed1]), 'hh:mm:ss') as [Avg time1],
    Interval(Avg([timeelapsed2]), 'hh:mm:ss') as [Avg time2],
    Interval(Avg([timeelapsed3]), 'hh:mm:ss') as [Avg time3]
Resident TimeElapsedTable
Group by [Subject];

 

Do you mean I should do something like this?

 

SwappedTable:
CrossTable(Avg,Subject)
    LOAD *
Resident AvgTable;

 

Because this returns an error, saying I have to have unique field names. I can verify that the field [Subject] is entirely unique across the whole of AvgTable, so I'm confused as to why this is happening. For reference, here is the general form of my table, AvgTable:

clipboard_image_0.png

I'm not sure what you meant by "try to keep s1 ,s2 as second column and use generic load" either. Can you help me with some sample syntax for crosstable and generic load in this case?

Channa
Specialist III
Specialist III

AvgTable:
Load
    [Subject],
    Interval(Avg([timeelapsed1]), 'hh:mm:ss') as [Avg time1],
    Interval(Avg([timeelapsed2]), 'hh:mm:ss') as [Avg time2],
    Interval(Avg([timeelapsed3]), 'hh:mm:ss') as [Avg time3]
Resident TimeElapsedTable
Group by [Subject];

CrossTable(AVG, TIME)
 LOAD  Subject,AvgTime1,AvgTime2,AvgTime3 resident AvgTable

if this dosent work try to load previous table into QVD instead of resident load from QVD

Channa
nougatitati
Contributor III
Contributor III
Author

You're awesome! It worked!

clipboard_image_0.png

Thanks so much, you've definitely saved me hours and hours of time.