我可以计算同一列中的值之间的差,然后返回另一列吗?怎么样?

时间:2019-01-09 20:36:12

标签: powerbi dax

我是在Power BI上学习DAX的新手,我必须计算表中具有不同日期的值之间的差异,如下所示(我很抱歉表示该表,上载时遇到了问题):

对象| ID |年

O_01 | 675 | 2018

O_02 | 415 | 2018

O_03 | 601 | 2018

O_01 | 969 | 2017

O_02 | 964 | 2017

O_03 | 672 | 2017

我想生成一个新表,该表显示每个对象的年份之间的差值,如下所示:

对象|差异

O_01 |差异1

O_02 |差异2

O_03 |差异3

我一直在寻找一种使用DAX来解决此问题的方法,但是我找不到解决方案,只能找到使用量度的解决方案,但是在我的实际问题中,我必须处理416个对象,我认为这不是一个好主意采取416措施。

如果有人知道解决此问题的方法,我将非常感激。具体地说,这是Power BI上的问题。

致谢。

1 个答案:

答案 0 :(得分:0)

Your problem is that you need to create a new measure (or many new measures) per Object. I would suggest looking at the source of the data and to use the M language (the upload of the data language) in order to create those measures.
As you're new to Power BI / Excel these are few references which I've found which could be helpful:

Theory:

https://community.powerbi.com/t5/Desktop/DAX-or-M-language-what-am-I-doing/td-p/334413

https://www.poweredsolutions.co/2015/02/04/getting-started-understanding-power-query-m-language/

https://hub.packtpub.com/use-m-functions-within-power-bi-querying-data/

And this one has some more hands-on examples:

https://blog.crossjoin.co.uk/category/power-query/