简体   繁体   English

合并或合并 power bi 中的两列

[英]Merge or combine two columns in power bi

I am not sure if my title is correct one, but here is the deal:我不确定我的标题是否正确,但这是交易:

I want to make a matrix visualization in Power Bi Desktop.我想在 Power Bi Desktop 中进行矩阵可视化。 I have fields: ARTICLE_ID and ARTICLE_NAME.我有字段:ARTICLE_ID 和 ARTICLE_NAME。 I would like to have both those fields in COLUMNS position in matrix data view.我想在矩阵数据视图中将这两个字段都放在 COLUMNS 位置。 And I need them to be in one row, no need to drill down... because it is one and the same thing... I need to have ARTICLE_ID and ARTICLE_NAME as two separate columns on the same level.而且我需要它们在一行中,不需要向下钻取...因为它是一回事...我需要将 ARTICLE_ID 和 ARTICLE_NAME 作为同一级别上的两个单独列。 without drilling.无需钻孔。 And also, I dont want to use concatenation or merging into some third column.而且,我不想使用串联或合并到第三列。 is that possible?这可能吗? thanks谢谢

1) I started with this sample data. 1)我从这个示例数据开始。

数据

2) I created a matrix and configured it as shown in the image below. 2)我创建了一个矩阵并如下图所示配置它。

矩阵

3) I clicked the forked arrows to show all levels. 3)我点击分叉的箭头来显示所有级别。

向下钻取

下钻后

4) In the Rows section of the formatting pane, I turned off "Stepped layout". 4)在格式窗格的行部分,我关闭了“阶梯式布局”。

阶梯式布局

5) In the Subtotals section, I turned off "Row subtotals". 5)在小计部分,我关闭了“行小计”。

小计

I don't know if this is exactly what you are looking for, but I think it is the closest I can come up with since you don't want to concatenate the columns together.我不知道这是否正是您要找的,但我认为这是我能想到的最接近的,因为您不想将列连接在一起。

If they are from the same table then just drag and drop them into the columns.如果它们来自同一个表,那么只需将它们拖放到列中即可。

The way a matrix works from my understanding in PowerBI is;根据我在 PowerBI 中的理解,矩阵的工作方式是;

Rows are just the headings/categories of the values.行只是值的标题/类别。 You might need to also go into the format tab, values, and make sure show on rows is on.您可能还需要进入格式选项卡、值,并确保在行显示已打开。

在此处输入图片说明

For example, let's say our value headings are rainy days and sunny days.例如,假设我们的价值标题是雨天和晴天。 Your columns are months.你的列是几个月。 The rows will be the 2 categories.行将是 2 个类别。 The values will be the values.值将是值。

As concatenation and "&" does not work in Power BI directquery you can use the below one:由于串联和“&”在 Power BI directquery 中不起作用,您可以使用以下一个:

[New_column_name] = if((table_name[column_name]="A" && table_name[column_name]="B"),"AB","NA") [new_column_name] = if((table_name[column_name]="A" && table_name[column_name]="B"),"AB","NA")

Thanks, Sachin Kashyap谢谢,Sachin Kashyap

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM