Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powerbi Power BI,获取最后一个可用值_Powerbi_Dax - Fatal编程技术网

Powerbi Power BI,获取最后一个可用值

Powerbi Power BI,获取最后一个可用值,powerbi,dax,Powerbi,Dax,你好 我的问题是,我有一组来自评估的数据,不是每个月都对所有商店进行评估,但我想用于评估的是最近的一个。 数据示例如下所示 Shop Date Total A 15/01/18 85 A 15/03/18 78 B 15/01/18 73 B 15/02/18 69 C 15/03/18 92 例如,在A店和C店,显示3月份的结果没有问题,但是对于B店,我

你好

我的问题是,我有一组来自评估的数据,不是每个月都对所有商店进行评估,但我想用于评估的是最近的一个。 数据示例如下所示

Shop     Date        Total
A        15/01/18    85
A        15/03/18    78

B        15/01/18    73
B        15/02/18    69       

C        15/03/18    92
例如,在A店和C店,显示3月份的结果没有问题,但是对于B店,我不能显示信息,因为如果我按月份过滤,我什么也得不到


那么有可能得到最后一个可用值吗?

这是一个非常复杂的问题,除非我遗漏了什么。使用
LASTNONBLANK()

我还从未见过有人发布一个方法来解决你的情况,尽管我见过一些在某些方面类似的方法

Matt Allington:演示如何在列末尾缺少数据时,在小计区域中正确显示最后一个值

马可·鲁索:这很有启发性,但它会一直持续到日期表中的日期用完为止

我并不是说这项措施将是最有效的,但它应该实现你所追求的:

Most Recent Balance = 
-- The first day of the period in context (not just for which we have data)
VAR context_first_date = FIRSTDATE(data[Date].[Date]) 

-- The last day of the period in context (not just for which we have data)
VAR context_last_date = LASTDATE(data[Date].[Date]) 

-- See if there are any transactions after the beginning of this period
VAR transactions_before_end = CALCULATE(COUNTROWS(data), FILTER(ALL(data), data[Date] <= context_last_date))

-- See if there are any transactions before the end of this period
VAR transactions_after_beginning = CALCULATE(COUNTROWS(data), FILTER(ALL(data), data[Date] >= context_first_date)) 

-- Find the last date for which there was a transaction
VAR transaction_last_date = 
    CALCULATE(
        MAX(data[Date]), 
        ALL(data[Date].[Date]),
        ALL(data[Date].[Day]),
        ALL(data[Date].[Month]),
        ALL(data[Date].[MonthNo]),
        ALL(data[Date].[Quarter]),
        ALL(data[Date].[QuarterNo]),
        ALL(data[Date].[Year]),
        data[Date] <= context_last_date)
RETURN 
IF(
    -- If there are either no transactions before the end of this period or none after the start, that means we are in a period 
    -- for which no data exists (e.g. the future) so show nothing
    ISBLANK(transactions_after_beginning) || ISBLANK(transactions_before_end), 
    BLANK(), 
    CALCULATE(SUM(data[Total]), data[Date].[Date] = transaction_last_date)
)
最近余额=
--上下文中周期的第一天(不仅仅是我们有数据的那一天)
VAR context\u first\u date=FIRSTDATE(数据[date].[date])
--上下文中周期的最后一天(不仅仅是我们有数据的那一天)
VAR context\u last\u date=LASTDATE(数据[date].[date])
--查看此期间开始后是否有任何交易
VAR交易记录结束前=计算(计数行(数据)、过滤器(全部(数据)、数据[日期]=上下文第一个日期))
--查找发生交易的最后日期
VAR事务处理最后日期=
算计(
最大值(数据[日期]),
全部(数据[日期][日期]),
全部(数据[日期][日期]),
全部(数据[日期][月份]),
全部(数据[日期][月号]),
全部(数据[日期][季度]),
全部(数据[日期][季度号]),
全部(数据[日期][年份]),
数据[日期]

根据上面给出的表格

看一看函数lastnonblank谢谢,我对公式有一个问题:
transaction\u last\u date=CALCULATE(MAX('Tabla:Calidad'[Fecha-Mes])、ALL('Tabla:Calidad'[Fecha-Mes])、'Tabla:Calidad'[Fecha-Mes],这是一个使用变量的单一度量。您的Power BI版本支持变量吗?
CALCULATE(SUM('Table'[Total]), FILTER('Table','Table'[Date]=MAX('Table'[Date])))