在 DAX 中为一年中的所有月份分配相同的值

问题描述 投票:0回答:1

我的数据集中有两个日期信息,并尝试完全填充表格的上对角线。

我可以通过这个方法计算对角线值,

Count Distinct Customer First Month of Year =
VAR selected_year= SELECTEDVALUE(table1[Year])
VAR selected_month=SELECTEDVALUE(table1[MonthNumber])
RETURN
CALCULATE(
    DISTINCTCOUNT(table1[CustomerID]),
    FILTER(table1, table1[Deposit_Year]=selected_year && table1[Deposit_Month]=selected_month)
)

但是,我需要将这些对角线值分配给一年中所有接下来的几个月,如下所示,

(行=表1(存款_年份)和表1(存款_月份))

(列=表1(年)和表1(月))

谢谢你,

维利

filter powerbi dax
1个回答
0
投票

尝试以下操作(但不确定)- 将

table1[Deposit_Month] <= selected_month
=
更改为
<=

Count Distinct Customer First Month of Year =
  VAR selected_year = SELECTEDVALUE(table1[Year])
  VAR selected_month = SELECTEDVALUE(table1[MonthNumber])
  RETURN
  CALCULATE(
    DISTINCTCOUNT(table1[CustomerID]),
    FILTER(
      table1,
      table1[Deposit_Year] = selected_year && 
      table1[Deposit_Month] <= selected_month
    )
  )
© www.soinside.com 2019 - 2024. All rights reserved.