In Power BI, is there a view or other way to show a single record as a list of key value pairs?

huangapple go评论126阅读模式
英文:

In Power BI, is there a view or other way to show a single record as a list of key value pairs?

问题

在Power BI中,是否有一种查看或其他方法可以将单个记录显示为键值对的列表?

我想要列出单个记录/行的值。其列标题将显示在第一列,而值将显示在第二列。在Azure Log Analytics中,这是一个默认功能,可以将每个单独的行进行旋转。在PowerShell中,我会将对象传递给Format-List,而不是Format-Table。

根据文档中的信息,我认为预期的解决方案是使用单个卡片。然而,有40列像这样:

列1 列2 列3 列N
值A1 值A2 值A3 值AN
值B1 值B2 值B3 值BN
...

当过滤记录#1时,需要显示如下:

列1 值A1
列2 值A2
列3 值A3
列N 值AN
...
英文:

In Power BI, is there a view or other way to show a single record as a list of key value pairs?

I'd like to list out the values of single record/row. Its column headings would be in the first column and the values in the second column. In Azure Log Analytics, this is a default feature with every individual row able to be pivoted. In Powershell, I would pipe the object to Format-List, rather than Format-Table.

Best I can tell from the documentation, the expected solution would be to use single cards. However, there are 40 columns like this:

Column1 Column2 Column3 ColumnN
ValueA1 ValueA2 ValueA3 ValueAN
ValueB1 ValueB2 ValueB3 ValueBN
...

That need to be displayed like this, when filtered for record #1:

Column1 ValueA1
Column2 ValueA2
Column3 ValueA3
ColumnN ValueAN
...

答案1

得分: 1

我认为你想要做的是将你的表格进行逆行转置。在Power Query中可以做到这一点 - 网上有很多相关资源。

如果你有这样的一个表格:

ID Key 1 Key 2 其他列 ++
1 A B ...
2 C D ...

你可以使用逆行转置技术,将这些关键列转换成一个新表格。新表格会是这样的:

ID 属性
1 Key 1 A
1 Key 2 B
2 Key 1 C
2 Key 2 D

然后你可以将这个表格作为你原始(维度)表格的一种事实表来使用。

所涉及的步骤如下:

  1. 在Power Query中,添加一个新的查询引用原始表格
  2. 删除你不想逆行转置或在表格中保留的任何列
  3. 选择你的主表键(以及其他你想保留为逆行转置的列 - 不管出于什么原因),然后选择"逆行转置其他列"
  4. 将新表格加载到你的模型中,并在主键列上建立原始表格和新表格之间的关系。

为了利用这个功能,你可以例如创建一个详细信息表格页面,并将原始表格的主列作为钻取过滤器添加进去。每当你想要通过某个特定选择进行钻取到详细信息页面时,请确保在可视化中使用原始主列。

英文:

I think what you are after is to unpivot your table. Do this in Power Query - there are plenty of resources on this online.

If you have a table like this:

ID Key 1 Key 2 Other cols ++
1 A B ...
2 C D ...

You can transform these key columns into a new table using the unpivoting technique. The new table will look like this:

ID Attr Val
1 Key 1 A
1 Key 2 B
2 Key 1 C
2 Key 2 D

And you can use this as a sort of fact table to your original (dimension) table.

The steps involved are as follows:

  1. In Power Query, add a new query referencing the original table
  2. Remove any columns you do not want to unpivot or retain in the table
  3. Select your primary table key (and other columns you want to retain as unpivoted - for whatever reason), and select "unpivot other columns"
  4. Load the new table to your model and establish a relationship between the original table and new table on the primary key column.

To utilize this, you can for example create a details table page and add the original table primary column as a drill-through filter. Whenever you want to drill through to the details page with a certain selection, make sure the original primary column is used in the visual.

huangapple
  • 本文由 发表于 2023年3月4日 04:17:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75631536.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定