在 Power BI 中,可以在一个度量值中使用另一个度量值作为筛选器。

huangapple go评论137阅读模式
英文:

use one measure value in another measure as a filter in power BI

问题

Max_date = MAX('418k'[Crawl_date]).

The above "Max_date" I am using in another measure then is throwing an error message.

ex - sales/day = CALCULATE(SUM('418k'[Sales_count]), '418k'[Crawl_date] = [Max_date])

error message - a placeholder has been used in a true/false expression that is used as a table filter expression.

If am using it directly then there is no error
ex - sales/day = CALCULATE(SUM('418k'[Sales_count]), '418k'[Crawl_date] = MAX('418k'[Crawl_date]))

But I would like to use the [Max_date] ( variable ) in the filter instead of MAX('418k'[Crawl_date]).

英文:

I am finding a measure (Max_date) from a date column (Crawl_date). I would like to use the value of that measures in another measure as a filter.-- "

Max_date = MAX('418k'[Crawl_date]).

The above "Max_date" I am using in another measure then is throwing an error message.

ex - sales/day = CALCULATE(SUM('418k'[Sales_count]),'418k'[Crawl_date] = [Max_date])

error message - a placeholder has been used in a true/false expression that is used as a table filter expression.

If am using it directly then there is no error
ex - sales/day = CALCULATE(SUM('418k'[Sales_count]),'418k'[Crawl_date] = MAX('418k'[Crawl_date]))

But I would like to use the [Max_date] ( variable ) in the filter instead of MAX('418k'[Crawl_date]).

答案1

得分: 2

你已经在某种程度上回答了自己的问题 - 只需使用一个变量来存储您的度量值:

例如 - 销售/天 = 
VAR _max = [Max_date]
RETURN
    CALCULATE (
        SUM( '418k'[Sales_count] ),
        '418k'[Crawl_date] = _max
    )
英文:

You have sort of answered your own question - just use a variable to store your measure value:

ex - sales/day = 
VAR _max = [Max_date]
RETURN
    CALCULATE (
        SUM( '418k'[Sales_count] ),
        '418k'[Crawl_date] = _max
    )

答案2

得分: 1

你可以使用变量来实现这一点:

ex - sales/day =
VAR _max_date = [Max_date]
RETURN
    CALCULATE ( SUM ( '418k'[Sales_count] ), '418k'[Crawl_date] = _max_date )

https://learn.microsoft.com/en-us/dax/best-practices/dax-variables

英文:

you can use variables for that:

ex - sales/day =
VAR _max_date = [Max_date]
RETURN
    CALCULATE ( SUM ( '418k'[Sales_count] ), '418k'[Crawl_date] = _max_date )

https://learn.microsoft.com/en-us/dax/best-practices/dax-variables

huangapple
  • 本文由 发表于 2023年3月31日 17:37:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75896959.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定