Power Bi 计算上个月的增长并将其显示在矩阵中

Power Bi Calculate Growth Over Last Month and Show it in a Matrix

我有一个下面的矩阵。我想计算 % Growth over month 并在矩阵中显示

字段

预期输出

Company August September GOLM % Total
EBS-EASEBUSINESS SOLUTIONS 5940 0 -100% 5940
    SWEETREAT CAFE 5940 0 -100% 5940
        M/S SPORTS ONE PHARMACY 1188 -100% 1188

尝试过的解决方案

我试过这个Solution。但它对我不起作用

GOLM = 
VAR SelectedMonth =
SELECTEDVALUE (
   Dates[Month],
     MONTH ( TODAY () )
 )

 VAR PrevMonth =
  SELECTEDVALUE (
   'Source Data'[Month Updates],
     MONTH ( TODAY () )
  ) - 1

  VAR Growth =
   CALCULATE(
   DIVIDE(
    SelectedMonth - PrevMonth,
    PrevMonth,
    0
    )
    )

    RETURN
    IF(
    SELECTEDVALUE('Source Data'[Month Updates]) = PrevMonth,
    SUM('Source Data'[SALES VALUE]),
    IF(
    SELECTEDVALUE('Source Data'[Month Updates]) = SelectedMonth,
    SUM('Source Data'[SALES VALUE]),
    FORMAT(Growth, "Percent")

     )
     )

错误

DAX 文件

这是我的 Dax 文件

也许你可以这样做;

首先使用建模窗格创建一个 DAX table;

Growth = 
VAR CurrentMonth = FORMAT(TODAY(), "MMMM")
VAR PrevMonth =  FORMAT(EOMONTH(TODAY(),-1), "MMMM")
VAR tmp1 = SELECTCOLUMNS('Source Data',
                "SV_PrevMonth", CALCULATE(
                                    SUM('Source Data'[SALES VALUE]), 
                                    'Source Data'[Month Updates]=PrevMonth), 
                "SV_CurrentMonth", CALCULATE(
                                    SUM('Source Data'[SALES VALUE]), 
                                    'Source Data'[Month Updates]=CurrentMonth), 
                "PN", 'Source Data'[ProductNameFull],
                "CN", 'Source Data'[CustomerNameFull],
                "CP", 'Source Data'[Company]
            )  
return tmp1

然后为您的 table

添加一个度量
GrowthPercentage = CALCULATE(DIVIDE(SUM(Growth[SV_CurrentMonth]) - SUM(Growth[SV_PrevMonth]), SUM(Growth[SV_PrevMonth]),0))*100

结果会是这样;

您应该能够在源数据 Table 本身中添加度量,如下所示:

GLM =
VAR Curr_Month =
    CALCULATE (
        SUM ( 'Source Data'[SALES VALUE] ),
        'Source Data'[Month Updates] = FORMAT ( EOMONTH ( TODAY (), 0 ), "mmmm" )
    )
VAR Prev_Month =
    CALCULATE (
        SUM ( 'Source Data'[SALES VALUE] ),
        'Source Data'[Month Updates] = FORMAT ( EOMONTH ( TODAY (), -1 ), "mmmm" )
    )
VAR GROWTH = ( Curr_Month - Prev_Month ) / Prev_Month
RETURN
    GROWTH

当然,您需要将度量的格式更改为百分比。

这是您要找的吗?