简体   繁体   English

Power BI 度量与过滤器对分子和分母的影响不同

[英]Power BI measure with filter affecting numerator and denominator differently

Building an accounting report, part of which is a ratio called "Receivables Turnover".构建会计报告,其中一部分是称为“应收账款周转率”的比率。 It's calculated as "Sales" / "Trade Receivables".它的计算方式为“销售额”/“贸易应收账款”。 The calculation component of this is straight-forward (using CALCULATE ), but I'm not able to wrap my head around how to filter this by date.这个计算组件很简单(使用CALCULATE ),但我无法理解如何按日期过滤它。 Here's why:原因如下:

The numerator - "Sales" - is filtered for the exact date ie "Get me the sum of sales in December 2018".分子 - “销售额” - 针对确切日期进行过滤,即“获取 2018 年 12 月的销售额总和”。 However, the denominator of this calculation is filtered until the date ie "Get me the sum of trade receivables until December 2018".但是,此计算的分母被过滤日期,即“让我获得截至 2018 年 12 月的贸易应收账款总和”。

So when I add a filter to the visual, it can be either filtered for the exact date OR filtered to be "on or before".因此,当我向视觉对象添加过滤器时,它可以针对确切日期进行过滤,也可以过滤为“在或之前”。 How can I make it so that the numerator and denominator are impacted differently?我怎样才能使分子和分母受到不同的影响? Is this possible?这可能吗? If not, is there a way to workaround this?如果没有,有没有办法解决这个问题?

I'm guessing each row of the receivable table contains a positive number for a debit or a negative number for a credit.我猜测应收账款表的每一行都包含一个借方的正数或一个贷方的负数。 In that case, the balance at a given point of time would be defined like below.在这种情况下,给定时间点的余额将定义如下。

Receivable Balance =
CALCULATE (
    SUM ( Receivable[Amount] ),
    REMOVEFILTERS ( 'Calendar' ),
    'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
)

For example, if you drill-down the calendar to December 2018, this measure will show the total of all records on or before the end of December 2018.例如,如果您将日历向下钻取到 2018 年 12 月,则此度量将显示 2018 年 12 月或之前的所有记录的总数。

Then you can use this measure to define the turnover ratio.然后您可以使用此度量来定义周转率。

Receivables Turnover = DIVIDE ( [Sales], [Receivable Balance] )

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

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