简体   繁体   English

Power BI IF 和 AND 函数

[英]Power BI IF, AND Function

I'm attempting to write a DAX Formula that tells me the number of days that a case is opened and closed, and from there to then tell me which case was closed above the average closure day (187) and what was closed below average.我正在尝试编写一个 DAX 公式,告诉我一个案例打开和关闭的天数,然后告诉我哪个案例在平均关闭天数(187)之上关闭,哪些案例在平均关闭天数以下关闭。

However I need an additional ask within the IF formula to included Cases with Status as Completed.但是,我需要在 IF 公式中额外询问以包含状态为已完成的案例。 I tried the following DAX, but this appears to ignoring the Status Completed我尝试了以下 DAX,但这似乎忽略了状态已完成

Avg to Closure = IF(And(Sheet1[# Days To Close]>=187, Sheet1[Status]"Completed","Above Average","Below Average")

Here is an example of my table.这是我的桌子的一个例子。 Table Example表格示例

I need a formula to ignore the 2nd account as this currently has a status as open.我需要一个公式来忽略第二个帐户,因为它目前的状态为打开。 Is this possible?这可能吗?

First, you might want a measure that calculates average days to close .首先,您可能需要一个计算平均收盘天数的度量。

daytoclose_avg =
CALCULATE(
    AVERAGE(Sheet1[# Days To Close])
)

No, you can build some intelligence for the Avg to Closure .不,您可以为Avg to Closure构建一些智能。 Meaning that it compares the row's days to close to the whole average and returns "Below" or "Above" based on this logic.这意味着它将行的天数与整个平均值进行比较,并根据此逻辑返回“低于”或“高于”。

Avg To Closure =
VAR avg_allcompleted =
CALCULATE(
    [daystoclose_avg],
    ALL(Sheet1),
    Sheet1[Status] = "Completed"
)
VAR avg_row = [daystoclose_avg]
RETURN
IF(
    avg_row > avg_allcompleted,
    "Above Average",
    "Below Average"
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM