基于列值应用计算的措施(即 SQL 术语中的案例陈述)

Measure to apply calculation based on column value (i.e case statement in SQL terms)

这里是 DAX 的新手。我正在尝试根据列的值或“类别”应用计算。

我已经进行了计算,但它只显示满足计算条件的行。我想做的是说如果值在“CancelRT”、“NoShowRT”、“FillRate”等中...然后执行此计算,否则将值保留在“newunits”中。

以下有效,但仅 returns 包含指定值的行:

Percentages = 
DIVIDE ( 
Calculate(
SUM ( MMP_Dashboards_WMH_PBI[NewUnits] ),  MMP_Dashboards_WMH_PBI[Revenue_center]="FillRate" ||MMP_Dashboards_WMH_PBI[Revenue_center]="CancelRT" ||MMP_Dashboards_WMH_PBI[Revenue_center]="NoShowRT" || MMP_Dashboards_WMH_PBI[Revenue_center]="ExamRt"
),

COUNTROWS ( VALUES ( MMP_Dashboards_WMH_PBI[Provider_Finance] ) ) 
)

我想看到的是 IF Revenue_Center IN ("FilRate","CancelRt","NoshowRT",ExamRt" 然后做计算,否则就用 NewUnits

我试过以下内容,但语法肯定不对:

Units=

IF (
    MMP_Dashboards_WMH_PBI[Revenue_center]) IN {"FillRate","CancelRt","NoShowRt","ExamRt"}

DIVIDE ( 
Calculate(
SUM ( MMP_Dashboards_WMH_PBI[NewUnits] ),
),

COUNTROWS ( VALUES ( MMP_Dashboards_WMH_PBI[Provider_Finance] ) ) 
)
)

提前感谢大家提供的任何帮助!

数据看起来像这样:

Provider_Finance   Revenue_Center       NewUnits
John               Surgical             47.000
OSBORN             Testing              1.000
RAZDAN             FillRate             1.000
RAZDAN             FillRate             1.000
ANDREW             Exams                120.000

当对报告进行分组时,我想根据收入中心为“FillRate”并计算“Provider Finance”(2) 和其他指标的数量来获得 Razdan 的平均值:

Provider_Finance   Revenue_Center       NewUnits
John               Surgical             47.000
OSBORN             Testing              1.000
RAZDAN             FillRate             1.000 --The average
ANDREW             Exams                120.000

在我的第一个代码示例中,returns 下面的数据集有效,但只包括填充率指标,因为它过滤掉了其他非计算值。

Provider_Finance   Revenue_Center       NewUnits
RAZDAN             FillRate             1.000 --The average

终于明白了

Units = 
 SUMX(MMP_Dashboards_WMH_PBI, IF (MMP_Dashboards_WMH_PBI[Revenue_Center]IN {"FillRate","CancelRt","NoShowRt","ExamRt"},
DIVIDE ( 
Calculate(
SUM ( MMP_Dashboards_WMH_PBI[NewUnits] ), MMP_Dashboards_WMH_PBI[Revenue_Center] IN {"FillRate","CancelRt","NoShowRt","ExamRt"}
),

COUNTROWS ( VALUES ( MMP_Dashboards_WMH_PBI[Provider_Finance] )) 
),MMP_Dashboards_WMH_PBI[NewUnits]
))