在一个维度内测量的比率显示在另一个维度上 [英] A ratio measured within one dimension shown across another dimension

查看:37
本文介绍了在一个维度内测量的比率显示在另一个维度上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了练习,我们假设我正在监控美国国内或国外汽车销售的百分比.

For the sake of the exercise, let's assume that I'm monitoring the percentage of domestic or foreign auto sales across the US.

假设我的数据集如下所示:

Assume my dataset looks like:

StateOfSale | Origin | Sales
'CA' | 'Foreign' | 1200
'CA' | 'Domestic' | 800
'TX' | 'Foreign' | 800
'TX' | 'Domestic' | 800

如何按销售州显示外国销售的百分比,但每个州在视觉中都是一条线/标记/条?

How would I show the percentage of Foreign Sales, by State of Sale, but each State is a line/mark/bar in the visual?

因此,对于 CA,外国百分比为 60%.对于 TX,外国百分比为 50%.

So for CA, the Foreign Percentage is 60%. For TX, the Foreign Percentage is 50%.

推荐答案

这就是 Tableau 的初衷!并且有很多很好的方法可以将此类问题可视化.

This is what Tableau was born to do!, and there are a lot of great ways to visualize this type of question.

使用名为总百分比"的快速表格计算并根据每个州计算该百分比.在下图中,StateofOrigin"在列中,Sum(Sale)"在行中,我使用 Table (Down) 计算.

Use a Quick table calculation called "Percent of Total" and compute that percentage according to each State. In the picture below, "StateofOrigin" is in Columns, and "Sum(Sale)" is in Rows, I compute using Table (Down).

除了显示文本百分比之外,您还可以绘制原始销售数字以获取有关各州之间销售数量的附加上下文.

You can also graph the raw sales numbers in addition to displaying the text percentage to gain additional context about the number of sales between states.

最后,如果您有很多州,将其绘制在地图上会很酷.为此,您可以创建百分比计算字段,然后过滤掉国内销售额.

Finally, if you've got a lot of states, it can be cool to plot it out on a map. You can do this by creating a calculated field for percentage and then filtering out the domestic sales.

字段名称:百分比

SUM([Sale])/SUM({FIXED [StateofOrigin]: SUM([Sale])})

这篇关于在一个维度内测量的比率显示在另一个维度上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆