计算同一行-不同列中数字之间的差异

问题描述

对不起,如果以前已经回答过,我就是找不到。我正在尝试计算同一行中各列之间的差异,与从Excel透视图中的特定值得出的差异相同。

表中第一行的意思是,我们有39个不同的客户在2019/01年首次注册,然后在2019/02年只有5个回购,在2019/03年只有2个回购,等等。

我想要一个新表,其中显示2019 / 01-2019 / 02、2019 / 01-2019 / 03等之间的差异,因此在2019/01下显示0,在2019/02下显示34,在2019/03下每行显示37个(基本上从该行的第一个值减去)

有可能吗?

Raw Data

PBI Visual-我可以创建第一个表,因为它是一个简单的计数,但是我无法在PBI中创建“损失率”表

解决方法

为您的表创建一个新的自定义列,如下所示-

column_january = "January"

现在可以进行客户活动,在报表中添加一个矩阵,并按如下所示配置矩阵属性-

enter image description here

通过对诸如“总计”,“子总计”和“每行级别”之类的属性进行一些更改,您将在下面的演示文稿中获得此信息-

enter image description here

立即失去客户,创建如下的衡量标准-

customer_lost = 

VAR current_year = MIN(your_table_name[activity date].[Year])

VAR customer_starts_with = 
CALCULATE(
    AVERAGE(your_table_name[customer]),FILTER(
        ALL(your_table_name),your_table_name[activity date].[Year] = current_year
            && your_table_name[activity date].[Month] = "January"
    )
)

RETURN IF(MIN(your_table_name[customer]) = BLANK(),BLANK(),customer_starts_with - MIN(your_table_name[customer]))

现在在报表中添加一个矩阵,并按如下所示配置矩阵属性-

enter image description here

随着诸如“总计”,“子总计”和“每行级别”之类的属性的一些更改,您将在下面的演示文稿中获得此信息-

enter image description here

您对客户流失的最终衡量标准将如下所示(将衡量标准类型转换为%)。只需复制丢失客户的矩阵,然后在演示文稿的“值”字段中将度量“客户丢失”替换为“客户丢失百分比”。

customer_lost_percentage = 

VAR current_year = MIN(difference[activity date].[Year])

VAR customer_starts_with = 
CALCULATE(
    AVERAGE(difference[customer]),FILTER(
        ALL(difference),difference[activity date].[Year] = current_year
            && difference[activity date].[Month] = "January"
    )
)

VAR customer_lost = IF(MIN(difference[customer]) = BLANK(),customer_starts_with - MIN(difference[customer]))

RETURN customer_lost/customer_starts_with
,

要使矩阵像您上面所说的那样,我必须使用

matrix

所以当我尝试将customer_lost代码替换为

customer_lost = 

VAR current_year = MIN(Month_Retention[FD_Date])

VAR customer_starts_with = 
CALCULATE(
    AVERAGE(Month_Retention[Customers]),FILTER(
        ALL(Month_Retention),Month_Retention[FD_Date] = current_year
            && Month_Retention[Activity_Date].[Month] = "January"
    )
)

RETURN 
IF(
    MIN(Month_Retention[Customers]) = BLANK(),customer_starts_with - MIN(Month_Retention[Customers])
)

它只是不能正常工作,因为我认为我替换了错误的东西。