powerbi - Split data into categories in the same row in Power BI
问题描述
I have a table that contains multiple columns with their named having either the suffix _EXPECTED
or _ACTUAL
. For example, I'm looking at my sold items from my SoldItems
Table and I have the following columns: APPLES_EXPECTED
, BANANAS_EXPECTED
, KIWIS_EXPECTED
, APPLES_ACTUAL
, BANANAS_ACTUAL
, KIWIS_ACTUAL
(The Identifier of the table is the date, so we have results per date). I want to show that data in a table form, something like this (for a selected date in filters:
+------------+----------+--------+
| Sold items | Expected | Actual |
+------------+----------+--------+
| Apples | 10 | 15 |
| Bananas | 8 | 5 |
| Kiwis | 2 | 1 |
+------------+----------+--------+
How can I manage something like this in Power BI ? I tried playing with the matrix/table visualization, however, I can't figure out a way to merge all the expected and actual columns together.
解决方案
It looks like the easiest option for you would be to mould the data a bit differently using Power query. You can UNPIVOT your data so that all the expected and actual values become rows instead of columns. For example take the following sample:
Date Apples_Expected Apples_Actual
1/1/2019 1 2
Once you unpivot this it will become:
Date Fruit Count
1/1/2019 Apples_Expected 1
1/1/2019 Apples_Actual 2
Once you unpivot, it should be fairly straightforward to get the view you are looking for. The following link should walk you through the steps to unpivot:
Hope this helps.
推荐阅读
- async-await - AttributeError:“ClientCreatorContext”对象没有属性“invoke_endpoint”
- javascript - 如何在 IE 中访问 JQuery Succes/Done 函数中的数组?
- powerbi - Power BI (Dax) 测量相同子类别项目但不同国家/地区之间的差异
- angular - 无法通过任何组件角度的拦截器或构造函数显示 ng -bootstrap toast。但是通过单击按钮可以正常工作
- python - Pyathena“s3_staging_dir”文件 - 我怎样才能得到这个文件名来使用它?
- encryption - 如何解密电报网络请求
- javascript - 在 Wordpress 中延迟内联脚本
- java - Spring Data JPA:仅按 java.time.LocalDateTime 列的日期部分排序
- google-apps-script - 如何在不更改 URL 的情况下重新发布 Web 应用程序
- javascript - 交互式更新下拉列表