Tableau创建表格矩阵?

时间:2015-09-04 00:22:12

标签: matrix tableau

我有一个看起来像这样的CSV文件。它是矩阵形式,其中单元格A1是空的。我希望在Tableau中将其显示为this

   a1,a2,a3
a1,1,0.2,0.3
a2,0.3,1,0.5
a3,0.6,0.7,1

如何在画面中构建此图来显示矩阵?

我尝试将measure name放在行和列字段中,measure values放在marks文本框中,但我最终得到的对角线值不是我想要的。

1 个答案:

答案 0 :(得分:0)

首先以表格的形式构建数据。

Tableau(以及大多数工具)的结构良好的CSV文件具有标记每列的单个标题行(因此跳过标题行中的第一个单元格是个问题)。然后,后面的每个数据行仅包含由列分隔的每个字段中的值(因此不应存在前导行标签)

在关系表中,订单并不重要。表中的行形成一个集合,而不是矩阵。

所以你的CSV应该看起来更接近

@interface QueueController : NSObject<NSURLSessionDelegate>

@property(nonatomic, weak) NSObject<QueueControllerDelegate>* delegate;
@property(atomic, strong) NSURLSession* session;
@property(nonatomic) NSURLSessionConfiguration* configuration;

+ (QueueController*)sharedInstance;

@end

@implementation QueueController {
- (void)application:(UIApplication *)application
handleEventsForBackgroundURLSession:(NSString *)identifier
completionHandler:(void (^)(void))completionHandler {
//...
}

TransferUploadModel:

    @interface TransferUploadModel : TransferModel <NSURLSessionTaskDelegate,
                                                    NSURLSessionDataDelegate>
    //...

    @end    


//Note TransferModel is a subclass of NSOperation
@implementation TransferUploadModel


- (id)initWithMedia:(MediaItem*)mediaItem_
   withTransferType:(TransferType)transferType_
      andWiths3Path:s3Path_
 andWiths3file_name:s3file_name_
andWithNSURLSession:session {
}


- (void)main {
    //NSOperation override
}



//
// Transfer upload started
//
- (void)uploadMedia {
    /**
     * Fetch signed URL
     */
    AWSS3GetPreSignedURLRequest *getPreSignedURLRequest = [AWSS3GetPreSignedURLRequest new];
    getPreSignedURLRequest.bucket = BUCKET_NAME;
    getPreSignedURLRequest.key = @"mypic.jpeg";
    getPreSignedURLRequest.HTTPMethod = AWSHTTPMethodPUT;
    getPreSignedURLRequest.expires = [NSDate dateWithTimeIntervalSinceNow:3600];

    // Important: must set contentType for PUT request
    getPreSignedURLRequest.contentType = self.content_type;
    NSLog(@"headers: %@", getPreSignedURLRequest);

    /**
     * Upload the file
     */
    [[[AWSS3PreSignedURLBuilder defaultS3PreSignedURLBuilder] getPreSignedURL:getPreSignedURLRequest] continueWithBlock:^id(AWSTask *task) {

        if (task.error) {
            NSLog(@"Error: %@", task.error);
        } else {
            NSURL* presignedURL = task.result;
            NSLog(@"upload presignedURL is: \n%@", presignedURL);

            NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:presignedURL];
            request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
            [request setHTTPMethod:@"PUT"];
            [request setValue:self.content_type forHTTPHeaderField:@"Content-Type"];

            @try {
                self.nsurlSessionUploadTask = [self.nsurlSession uploadTaskWithRequest:request
                                                             fromFile:self.mediaCopyURL];
                [self.nsurlSessionUploadTask resume];
                //
                // Delegates don't fire after this...
                //
            } @catch (NSException* exception) {
                NSLog(@"exception creating upload task: %@", exception);
            }
        }
        return nil;
    }];
}


//
// NSURLSessionDataDelegate : didReceiveData
//
- (void)URLSession:(NSURLSession *)session
          dataTask:(NSURLSessionDataTask *)dataTask
    didReceiveData:(NSData *)data {
    NSLog(@"...");
}

//
// Initial response from server with headers
//
- (void)URLSession:(NSURLSession *)session
          dataTask:(NSURLSessionDataTask *)dataTask
didReceiveResponse:(NSURLResponse *)response
 completionHandler:
(void (^)(NSURLSessionResponseDisposition disposition))completionHandler {
    NSLog(@"response.description:%@", response.description);
    completionHandler(NSURLSessionResponseAllow);
}

//
// Upload transfer in progress
//
- (void)URLSession:(NSURLSession *)session
              task:(NSURLSessionUploadTask *)task
   didSendBodyData:(int64_t)bytesSent
    totalBytesSent:(int64_t)totalBytesSent
totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend {
    @try {
        NSLog(@"...");
    } @catch (NSException *exception) {
        NSLog(@"%s exception: %@", __PRETTY_FUNCTION__, exception);
    }
}

//
// Upload transfer completed
//
- (void)URLSession:(NSURLSession *)session
              task:(NSURLSessionTask *)task
didCompleteWithError:(NSError *)error {
        NSLog(@"...");
} // end URLSession:session:task:error


@end

通常,Tableau的主要用途是显示数据的汇总摘要,而不是显示每个单独的数据行。因此,您可以将measure_names放在文本或标签架上的列和measure_values上,以获取每个度量的摘要(默认为总和)

如果您只想查看表中的基础数据行以进行诊断,最简单的方法是使用视图数据按钮或菜单命令。

如果要在表格中构建显示所有数据(无需汇总)的可视化,您有两种方法可以使用。最简单的方法是,如果数据中有唯一的主键,则可以将其放在行架上,以便为数据中的每一行输入一行。

如果您的数据行没有主键,则可以从“分析”菜单中关闭聚合度量,但随后您将在每个表格单元格中看到多个值。然后,为了在数据中为每一行输入一行,将计算索引()放在行架上并将其更改为离散。