动态计算基于Slicer-Powerbi的差异列
我有一个带有季度数量数据的桌子,还有一个切片机,可让您选择要查看每码的四分之一/年。切片机具有2019Q1至2021Q4的选择。我需要创建动态差异列,该列将根据切片机中选择的四分之一/年进行调整。我知道我需要使用计算/过滤器来创建一个新的措施,但是是PowerBi的初学者,并且不确定如何编写该公式。
Example of raw table data:
Code | 2019Q1 | 2019Q2 | 2019Q3 | 2019Q | 2020Q1 | 2020Q2 | 2020Q3 | 2020Q4 |
---|---|---|---|---|---|---|---|---|
11111 | 232 | 283 | 289 | 19 | 222 | 283 | 289 | 19 |
22222 | 117 | 481 | 231 | 31 | 232 | 286 | 2 | 19 |
11111 | 232 | 397 | 94 | 444 | 232 | 553 | 0 | 188 |
22222 | 117 | 411 | 15 | 14 | 232 | 283 | 25 | 189 |
示例如果2019Q1和选择2020Q1:
代码 | 2019Q1 | 2020Q1 | 差异 |
---|---|---|---|
11111 | 232 | 222 | 10 |
22222 | 117 | 481 | -364 |
11111 | 232 | 397 | -165 |
22222 | 117 | 411 | -294 |
I have a table with quarterly volume data, and a slicer that allows you to choose what quarter/year you want to see volume per code for. The slicer has 2019Q1 through 2021Q4 selections. I need to create dynamic difference column that will adjust depending on what quarter/year is selected in the slicer. I know I need to create a new measure using Calculate/filter but am a beginner in PowerBI and am unsure how to write that formula.
Example of raw table data:
Code | 2019Q1 | 2019Q2 | 2019Q3 | 2019Q | 2020Q1 | 2020Q2 | 2020Q3 | 2020Q4 |
---|---|---|---|---|---|---|---|---|
11111 | 232 | 283 | 289 | 19 | 222 | 283 | 289 | 19 |
22222 | 117 | 481 | 231 | 31 | 232 | 286 | 2 | 19 |
11111 | 232 | 397 | 94 | 444 | 232 | 553 | 0 | 188 |
22222 | 117 | 411 | 15 | 14 | 232 | 283 | 25 | 189 |
Example if 2019Q1 and 2020Q1 are selected:
Code | 2019Q1 | 2020Q1 | Difference |
---|---|---|---|
11111 | 232 | 222 | 10 |
22222 | 117 | 481 | -364 |
11111 | 232 | 397 | -165 |
22222 | 117 | 411 | -294 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Power BI不起作用。这是一个Excel Pivot表设置。您没有任何参数可以区分第一,第三或第二行。它们具有相同的代码,因此Power BI将汇总其量。您可以引入一个隐藏的索引列,但是为什么不只是坚持Excel呢?问题的功率bi批准是将表格(堆叠)到代码,四分之一和卷列,为Minuend和Subtrahend创建2个独立的切片机表,然后根据2个切片机的选定值来计算您的汇总差异。
Power BI doesn't work that way. This is an Excel pivot table setup. You don't have any parameter to distinguish first and third or second and fourth row. They have the same code, so Power BI will aggregate their volumes. You could introduce a hidden index column but then why don't you simply stick to Excel? The Power BI approch to the problem would be to unpivot (stack) your table to a Code, Quarter and a Volume column, create 2 independent slicer tables for Minuend and Subtrahend and then CALCULATE your aggregated differences based on the SELECTEDVALUE of the 2 slicers.